I have a problem and I'm having trouble finding the optimal aproach to it. A colleague recommended the Visitor pattern but I'm not sure if what I want can be done using Visitor. Even if it can be done there are some serious issues about clarity if I use that approach.
I'm trying to serialize / deserialize settings and finding that I need to add the same helper methods to a number of classes (bad). I'd prefer to move these helpers out of the classes I'm putting them in (which should have no code dealing with serialization / deserialization but am unsure how to factor it out) and into a centralized spot.
Currently I'm trying to get / set parameters on objects (buttons, other menu components, ...) which are contained in parent menu classes. I don't actually want these parent classes to have helper methods (both because it is causing code duplication across the parent classes and because the parent classes shouldn't "care" or "know" about these serialization / deserialization details)
The easiest way (of course) would be to have centralized methods that take a "void *" pointer. That aproach would be easy to read but (owing to the "void *") a bit dirty. The "void *" would be a reference to each of the parent (menu) classes I need to work on.
Given that I have m things that I have to get parameters to and from (and I can only access them through the n parent menu classes), and the parameter lists can be different... can I really use Visitor for this? Is it the proper pattern to use?