I have decided to split my application into 3 separate modules - one "abstract" with almost all application logic (anyone looking at the code can tell WHAT it does), one "implementation" module with all specific implementation layers (like db, connections, etc) and one small "runtime" module that maps implementation with abstraction (configures factories etc) and starts the app.
So I have an abstract PortListener class that can handle specific messages recevied from port. Most of the logic is done in this class, only specific implementation details (like port opening, closing, reading bytes from port and converting it to domain message) are moved to the PortListenerImplementation. PortListener have abstract methods called "listen()" - it should open port and add itself as a listener to the port, and "close()" - remove listener, close port. And there is method called "handleMessage(Message message)" that handles messages and do whatever it is needed.
How to obligate PortListenerImplementation to call "handleMessage()" in its own "real" listener method? Is there something like Reversed Template Method? Or maybe I've just gone too far? :D
Thx
Aucun commentaire:
Enregistrer un commentaire