I have a case in which I have two base processes for ordering. One follows a standard process. One follows a custom process. I also have abstractions that follow specific product lines for ordering as such:
StandardOrderBase
CustomOrderBase
HardProductOrder
- Inherits StandardOrderBase
SoftProductOrder
- Inherits StandardOrderBase
LeftProductOrder
- Inherits CustomOrderBase
RightProductOrder
- Inherits CustomOrderBase
Each product order class has some extra fields that are specific to the product that need to be inserted into the ordering process. They also have distinct validations that must occur.
The base classes contain all the standard fields that need to be sent into the ordering service. The subclasses would have additional fields.
How would I architect a means to calling a base Insert function that would take in the subclass's additional fields and utilize the base class fields into a generic Insert for both StandardOrder and CustomOrder. Or I guess I should ask -- what's the preferred pattern?
Preferrably, I'd inject into the constructor of a single OrderRepository. Then the OrderRepository.Insert call would call the Insert function of the injected object.
Aucun commentaire:
Enregistrer un commentaire