Hey Rahul, consider using enum for such cases: enum OrderStatus { COMPLETED, IN_PROGRESS, PENDING }. This gives you better type saftety and adds more context to the contants.
Even better you could create an internal enum in the Order class and expose methods like: isPending(); isInProgresss(); isCompleted(). This way the status does not need to leak to the rest of the application.
hey Maciej, you are right we can use enum for such case. But, we can also expose methods as you said.
This way the status does not need to leak to the rest of the application
We are just exposing the status codes across the package, not the status of any particular order. We can always hide the status of order from outside entity.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Rahul, consider using enum for such cases: enum OrderStatus { COMPLETED, IN_PROGRESS, PENDING }. This gives you better type saftety and adds more context to the contants.
Even better you could create an internal enum in the Order class and expose methods like: isPending(); isInProgresss(); isCompleted(). This way the status does not need to leak to the rest of the application.
hey Maciej, you are right we can use enum for such case. But, we can also expose methods as you said.
We are just exposing the status codes across the package, not the status of any particular
order. We can always hide the status of order from outside entity.