Using enum vs Boolean?

Even ignoring the possibility of adding more status types in the future (which is certainly one good argument for an enum), I think an enum is absolutely the right way to go. You are not modelling a boolean condition, you are modelling the status of an application. Think about it: the application's status is not true or false, it's active or inactive! A status enum will represent this in the most natural way.

You also get a lot of built in advantages from using an enum, such as having a text description of each status tied directly to it, so you don't have to do things like

String text = application.isActive() ? "Active" : "Inactive";

You can just do

String text = application.getStatus().toString();

Additionally, you can tie specific behavior directly to each status with abstract methods that each enum implements differently, associate specific data with each status, etc.

You can also easily allow a boolean isActive check that is based on the status... you can't easily do that the other way around if you just store a boolean.

public boolean isActive() {
  return status == Status.ACTIVE;
}

And the fact that null shouldn't be a valid status is irrelevant... just ensure that any classes that store the status (say, your EmploymentApplication class or whatever) throw a NullPointerException if anyone tries to set a null status on it.


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.