mardi 18 juin 2019

Architecture design

I've been stumbling upon a nice architecture pattern for the following problem and can't find anything good. How would you design something like this?

There is an entity that can perform 4 basic actions. Each action requires an Input and Output parameter, i.e.

interface IEntity<TInputOp1, TOutputOp1, TInputOp2, TOutputOp2,
TInputOp3, TOutputOp3, TInputOp4, TOutputOp4> {
  TOutputOp1 Operation1(TInputOp1 input);
  TOutputOp2 Operation2(TInputOp2 input);
  TOutputOp3 Operation3(TInputOp3 input);
  TOutputOp4 Operation4(TInputOp4 input);
}

I need this to have templates because after this there are 2 abstract entities that implement specific cases with specific parameters.

class ConcreteEntity1<ConcreteINputOp1, ConcreteOutputOp2, ...> : IEntity<ConcreteINputOp1, ConcreteOutputOp2, ...> {}

class ConcreteEntity2<ConcreteINputOp1, ConcreteOutputOp2, ...> : IEntity<ConcreteINputOp1, ConcreteOutputOp2, ...> {}

these 2 classes handle 90% of the needed functionality, but there are cases when some specific implementation is needed for a specific Input parameter, i.e.

class SuperSpecificImpl : ConcreteEntity1<SuperSpecificInputOp1, ...>

and this is all good, but this code looks kinda overwhelmed with all these templated parameters, so I'm looking for a different kind of an architectural pattern that would handle nicer such a problem.

From my last read of Gang of four book, I don't recall any appropriate pattern, but maybe I missed something.

Any suggestions are welcome.

Aucun commentaire:

Enregistrer un commentaire