According this class diagram, whose purpose is to model the generation of several types of documents:
bigger size available here: http://ift.tt/1EB0Wh7
The client code will make use of the DocumentGenerator class, which is a Document factory, describing the type of document needed, and the service (the inspection is optional, only required for dispatch documents).
I'm struggling with the classes coloured in red. If all the insurance companies used the same document models for invoices, estimates, etc, this wouldn't be much of a problem. But there's one company that needs a different dispatch document model to be printed, and this is very likely to happen with more companies, not only with the dispatch but also with the rest of the documents.
Guess what would happen if I specialized each of the document subclasses for each company? It would be a nightmare of code duplication.
Two design patterns (strategy or decorator) might meet my requirement in order to favor composition over inheritance, but I can't figure out how to capture the idea.
Any suggestion is most welcome.
This is a link to the XMI file of this diagram, in case you want to use it: http://ift.tt/1AYZIi6
Aucun commentaire:
Enregistrer un commentaire