Naming conventions: "State" versus "Status" [closed]

IMO:

status == how are you? [good/bad]

state == what are you doing? [resting/working]


It depends on the context

State generally refers to the entire state of an entity - all its values and relationships at a particular point in time (usually, current)

Status is more of a time-point, say, where something is at in a process or workflow - is it dirty (therefore requiring saving), is it complete, is it pending input, etc

I hope that helps you in your decision.


Typically I will use State to mean the current condition of an object or the system as a whole. I use status to represent the outcome of some action. For example, the state of an object may be saved/unsaved, valid/invalid. The status (outcome) of a method is successful/unsuccessful/error. I think this jibes pretty well with the definition of status as "state or condition with respect to circumstances," the circumstances in this case being the application of an action/method.


Another (entirely pragmatic) reason to prefer state over status is that the plural is straightforward:

  • state -> states
  • status -> statuses

And believe me, you will sooner or later have a list or array or whatever of states in your code and will have to name the variable.