Reputation: 3989
What is the best way to model the status
of an Order
?Currently I am doing it the dirty way,by hardcoding like below
class Order{
...
String orderStatus;
...
public Order(){
...
orderStatus = "pending";
}
}
Later on when the status is changed to say confirmed
,I would
myorder.setOrderStatus("confirmed");
But,I begin to smell it is not the right way..What should be the correct way of modelling it?Should I use Enumerations?..
Upvotes: 1
Views: 522
Reputation: 1766
enum is good for the situation that changes very infrequently. But it will very be very convenient to change is you keep them in datebase.
Upvotes: 0