Typical composite pattern books shows leaner examples (obviously) where all composite items are somewhat relatable and often use one common method name for illustration like name()
in folder and files example.
I have deployed composite pattern in project where it makes good sense as in 'whole-part relationship' in a tree like structure. However they really have only two common attributes (=methods), rest of their attributes or properties of each node are quite different although relatable.
So I ended up with a lot of specific functions for each derived type in the base CompositeItem
class and by that I mean like 10 to 15 methods.
Since I have not really seen composite in action on this scale so I am looking for validation, does this sound normal or there any red flags?
I know I haven't included too specific information about project but given all items share only 2 methods but each have 10 to 15 different methods unique to that derived item only , does this sound okay and in general compliance of the pattern?
Aucun commentaire:
Enregistrer un commentaire