Say I have different types of operations which i need to perfom. I have an abstract class 'BaseOperation' which has all the information common to all operations. Now i need to categorize these operations based on an attribute and then further categorize every operation in each category based on some other attribute as shown in figure below. The goal is to log the operation type and subtype to prioritize investigation in case of any failures.
The way i thought i would do this is: I can have two enums corresponding to type and subtype in 'BaseOperation'. I can define a additional layer of abstract classes deriving the base which set the type of the operation and have operations derive the class of their type. The subtype for each operation can be set foreach operation individually.
I am not sure if this will be the best thing to do and if there is any design pattern i can follow for this scenario (i couldn't find any yet). Also i need this design to be extendable, say i want another attribute to be added for each operation (which i can easily do above by adding another enum in base and setting it again for each operation).
Aucun commentaire:
Enregistrer un commentaire