I was just starting a new coding project. I may be ahead of myself, but I've gotten kinda stuck. I wanted to implement an Abstract Factory for the GUI, similar to the example on Wikipedia. However various systems have their own parameters for creating windows. At present I have come up with the following solutions to my dilemma:
- Create a type which varies based on compiler directives
- Don't use compiler directives and just put everything in a type that contains every possible data member
- Create a polymorphic hierarchy and use dynamic casting inside each window function
- Use some sort of intermediate singleton that holds the information. This seems esp. unhelpful and would likely also involve casting.
- Use a different pattern, such as builder instead.
My objective is to create high level interfaces that are uniform, so that creating a window, etc. is the same for all platforms.
I hesitate to do #5 simply because it seems like this would be a common enough problem that there should already be a solution. This is just a toy, so it's more about learning than building a practical application. I know I could use existing code bases, but that wouldn't achieve my real objective.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire