Statement:
There are two choices:
WorkItemState is an emum and can be : SCHEDULED, READY, SUBMITTED, EXECUTING, COMPLETED
- Create single method : updateWorkItemState(workItemId, workItemState)
- Create multiple methods : markAsCompleted(workItemId), markAsSubmitted(workItemId), markAsExecuting(workItemId) etc.
In first approach, I am exposing work item states to client while in second approach I have to create multiple methods i.e one for each state.
I also have to check that state transition can be applied only if current state is valid. Ex- If work item is in EXECUTING state, then only it can be completed.
Which of the two approach seems better in terms of readability, maintainability and extensibility?
Aucun commentaire:
Enregistrer un commentaire