samedi 4 juin 2022

Is there a way of avoding diamond kind problems this OO Design

I am problems with my OO design. I have an event processing use case where I am using templates for various kinds of logic involved during event processing e.g transaction handling, processing template based on events e.g update, insert, etc. however, there is some common processing logic on concrete implementation as well which is currently creating diamond problems. Is there a better way to model them?

AbstractEventProcessing (batch processing, txn handling etc with construction deps)
^
|
|-------|------------------------------| 
|       UpdateEventProcessing          InsertEventProcessing
|       (template for processing, no construction deps)
|
|----------------------------|
AbstractEvent1Processor      AbstractEvent2Processor
(parsing for event1 etc.)    ...
constrcution deps            ^
^                            |
|                            ConceretUpdateEvent2Processor
|                            (needs UpdateEventProcessing) 
|
|-------------------------------|           
ConcreteUpdateEvent1Processor   ConcreteInsertEvent1Processor   
(needs UpdateEventProcessing)



However, the template is the same for Update and Insert for all the Event processors which lead to problems of having 2 base class (AbstractEvent1Processor & AbstractEventProcessor). Is there are some other ways of modeling these? Also, since these templates are used in many concrete implementations how do not repeat testing the same things at different places

Aucun commentaire:

Enregistrer un commentaire