Suppose that there is a connection process to a specific server the connecting process has multiple phases or steps, so we can move to other phases from a specific phase.
In the development of this library (connection), the State pattern has been used for establishing a connection. you can take a look at the state diagram of a connection process:
In each phase, we are doing some operations that the result of those operations can cause the movement to other phases.
I have a connection class that implements the IConnectionContext interface so the connection class is the context of states. (according to the state pattern UML, we have some states that we should pass a context to them by a constructor).
How can I alter the implementation of phases and how can I change my starting point (in a specific phase we may need to gather data from a previous phase) rewriting or duplicating the connection class?
Can decorator pattern or proxy pattern be helpful in this problem?
Aucun commentaire:
Enregistrer un commentaire