Most of my C ++ application uses classes to describe a data model, for example. something like ClassType (which actually emulates reflection in plain C ++).
I want to add a new module to my application and he needs to use these ClassType, but I prefer not to add dependencies from my new module to ClassType.
So far I have had the following alternatives:
- It does not make it independent and introduces a dependency on ClassType, at the risk of creating more "spaghetti dependencies" in my application (this is my least preferred solution).
- Introduce a new class, for example. IType, and let my module depend only on IType. ClassType should then inherit from IType.
- Use strings as an identification method and forcing users of the new module to convert ClassType to string or vice versa, when necessary.
- Use GUIDs (or even simple integers) as identifications, also requiring conversions between GUIDs and ClassType
How far should you try to go when decoupling modules in an application?
- just enter the interface and let all other modules rely on the interface? (e.g. in type description IType)
- even separate it further using other identifiers like strings or GUIDs?
I am afraid that, having separated it too far, the code becomes more unstable and more difficult to debug. I saw one such example in Qt: signals and slots are connected using strings, and if you make an input error, the functionality does not work, but it still compiles.
How far should you block your modules?