java - Using enum vs Boolean? -


this may seem generic, in fact, making decision on need use.

what working on involves employment applications, in need marked @ point active or inactive. when application submitted, default active. reasons, might later set inactive. can 1 of these , never null(in case changes anything).

i using java + hibernate + postgressql, in case makes difference. first instinct use boolean solution acts flag, have coworkers have suggested using enums or ints more of status rather flag.

i have solved problems such using of above solutions, , seem transparent eachother.

is there 1 way better situation?

it totally depends on requirement/specification. if want record status active or inactive, best way use boolean.

but if in future, have status such as,

  • active
  • inactive
  • suspended
  • blocked

enums perfect you. in case, now, boolean sufficient. don't try overcomplicate things early, you'll lose focus in design & development of system.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -