Currently, we have an business entity can be represented both as an enum or as a class.
The class implementation is easier and make business logic more clear. But there is probability of 50% that the requirements will change and an enum representation will make our life easier.
Concrete example
An entity has title and color. Color is editable, so there 2 ways
- entity is an enum – there is another class with mapping from entity to its color.
- entity is a class – just one more fiels for color, no problems.
Future change requirement – there should be rules associated with each entity
- entity is an enum – the rules are hard coded in the code
- entity is a class – there are needed few more classes for mapping and also an UI that will allow user to specify them.
In case the set of rules is static, the second option is an overkill.
So, in case we will need to transform the class to enum, are there any recommendations about this process ?
EDIT
The set of entities is limited and unlikely to be changed by user.
Thank you in advance.
In case you want some functionality from enums and some from classes, then you could use mix of these: