In program code and database it is very often needed to name variable or field
that describes current "state" or "status" of an object or a record. What is the correct name, though?
That depends on context, and the meaning is NOT exactly same, and it is not arbitrary.
- "state" is specific, where value can be one of pre-defined known distinct values, with conditions, like in context of "state machine", i.e. state of shopping cart: empty, open, closed etc.
- "status" is broader and is a result of an action or activity, where it could indicate an error or also include resulting state, i.e. status of adding item to shopping cart error for insufficient funds.
So simple rule for programming: when all possible values for an fields are known and defined better name "state", and when all values are not known or defined that this is a "status".
"systems engineering definition:
- A system is in a certain "state" at a point in time when the system meets a pre-defined set of criterion, i.e. on shopping website, a user's shopping cart enters a different state when the customer adds an item to it.
- A "status", in the context of states of a system, describes the transition into a state. For example, the user of our online shop may attempt to add an item to their cart. The transition into the state that describes the item being in the cart may be blocked if the status of the transition signals an error (i.e. the item is out of stock).
No comments:
Post a Comment