Hi,
I have an Entity (call it WorkItem) which has a Status field, an Enumeration.
Thing is I have multiple types of WorkItem which are exactly the same on all aspects (fields, UI, …) EXCEPT for the Status Enumeration.
The type of the WorkItem is indicated by an association to a WorkItemType
Some WorkItem types have 3 statusses, others have 5, …
So, I think I have those options ahead of me:
a) Use inheritance on the WorkItem to go changing the StatusEnumeration. This seems a bit overkill as I’d have to add lots of code around a discriminator field and would end up with a total mess. Also adding new WorkItem types would require code changes.
b) Use a method on the Enumeration that returns a List of the avaiable Statusses for a WorkItemType. I would avoid importing WorkItem from the Enum by passing a String id instead of the WorkItemType instance. That would need manual steps on the UI to display the valid statusses. New types would just need changes on the Enumeration.
But I think, what would be nicest would be Option c): Override the Enumeration directly in WorkItem when using the record. I would have different StatusEnumeration child classes for each type and then, somehow, when using the WorkItem the appropiate child class would be on the Status field. – This way I do not need to do anything outside the Entity: all UI elements, rest etc would pick the right Enumeration as long as the Entity.workItemType is properly set.
Of course, there’s option d) store this on a WorkItemStatus Entity and use an associacion with a filter but, again, needs lots of things in a lot of places for something quite simple.
Thous WorkItemType might change overtime, the kinds of Status Enumerations I need is quite short (maybe 5) as most Types share the same enumeration.
Is Option c) feasible? Can someone point me in the right direction?
Thanks,
Marc