How can I define some rules or additional effects of an action and select it dynamically?
For exemple, let's imagine a FinancialProduct, which can be a Share or a Bond (or something else, doesn't matter), each of them having a Hedge (risk insurance). Now while there are several different kind of Hedge, their number is still finite, and their business is known beforehand, it is just the Hedge / FinancialProduct association that can be chosen at runtime (creating new rulesets at runtime can be interesting too, but that could be another question for another time).
How could I implement this kind of behaviour ? I don't want to have many duplicate of the same hedge() method in my FinancialProduct
If the Hedge business is implemented in a different class, how can I expose FinancialProduct (its caller ?) properties to eventually modify them for exemple ? Or modify a property from a different class (a Portfolio which contains a list of owned or available FinancialProducts for exemple ?)
Aucun commentaire:
Enregistrer un commentaire