I have the following data types and I'm struggling to implement a good design to create instances for different types.
Events: I have different type of events (EventA, EventB etc.)
- Each event might have subtypes. For example,
EventAAandEventABare subtypes ofEventA,likewiseEventBAandEventBBare subtypes ofEventB. - Each event has
sourceandoutputbut the types differ. For exampleEventAAhasList<String>as source,EventBBhasintas a source. Same thing with the output.
At the end, I need to create EventAA, EventBA with their source and outputs. I tried to apply Abstract Factory design pattern to create events, defined Event, EventSource, EventOutput as abstract class. Also, created EventAFactory and EventBFactory classes. Although, my sub events EventAA and EventAB has source and output, types may differ. Therefore, I couldn't generalize the createEvent() method. For each different type of inputs, I defined a createEvent(type, source, output) method but that doesn't feel right. Use cases for AbstractFactory design pattern online doesn't have subtypes like me (EventAA etc.) and I confused.
Aucun commentaire:
Enregistrer un commentaire