My scenario involves the following classes:
I have three types of Peer
that creates a RegistryType
instance because its methods are needed. Same for Identity
class. Each PeerType
need 0 or all the RegistryType
methods in order to accomplish their work. Every Peer
is then run by creating a Server
instance that makes use of one of the methods defined by the Peer
by passing a callback.
What I'm trying to achieve is to solve the tight coupling between the PeerType
classes and the RegistryType
class. My idea is to define a general Peer
class from which every type inherits and define the dependency with the RegistryType
there.
The target language is Python so either constructing the Peer
s with a RegistryType
or a Registry
is ok.
Even after defining a new Peer
class to encapsulate the RegistryType
I reckon the two classes are still tight coupled so (maybe) a solution would be to pass a RegistryType
instance to the Peer
class instead of constructing it inside its constructor.
I hope to receive some great suggestions. Thanks.
EDIT1: I'll try to be more specific.
Every PeerType
implements some logic that is passed as argument to the run
method of the Server
. This method depends also on the OTT_RPC
class because it needs the callback_ottrpc
function to create the HandshakeServer
and accomplish the handshake (start_handshake
).
My first problem is that, each peer type is run by a class Server
, but Holder
offers two different services that should be passed to the run
method in contrast Verifier
offers only one, so I need to solve this inconsistency.
Second, the circular dependency between Server
, HandshakeServer
and OTT_RPC
.