Issue
This may initially seem generic, but in fact, I am actually making the decision on which I need to use.
What I am currently working on involves Employment Applications, those in which will need to be marked at some point Active or Inactive. When an application is submitted, it will default to Active. For certain reasons, it might later be set to Inactive. It can only be one of these and never null(In case this changes anything).
I am using this with Java + Hibernate + PostgresSQL, in case this also makes any difference. My first instinct is to use Boolean as my solution so that it truly acts as a flag, but I have coworkers who have suggested using enums or ints as more of a status rather then a flag.
I have solved problems such as this using all of the above solutions, and they all seem somewhat transparent to eachother.
Is there one way that is better for this situation?
Solution
It totally depends on your requirement/specification. If you only want to record the status as active or inactive, the best way is to use boolean
.
But if in the future, you will have a status such as,
- ACTIVE
- INACTIVE
- SUSPENDED
- BLOCKED
Enums is perfect for you. In your case, for now, a boolean is sufficient. Don't try overcomplicate things too early, you'll lose focus in your design & development of your system.
Answered By - Buhake Sindi
Answer Checked By - Robin (JavaFixing Admin)