For simple objects, it's usually easy to have a "state" attribute that's a string and storeable in a database. For example, imagine a User class. It may be in the states of inactive, unverified, and active. This *could* be tracked with two boolean values – "active" and "verified" – but it could also use a simple state machine to transition from inactive to unverified to active while storing the current state in that "state" attribute. Very common, right?

However, now imagine a class that has several more boolean attributes and, more importantly, could have lots of combinations of those. For example, a Thing that may be broken, missing, deactivated, outdated, etc. Now, tracking state in a single "state" attribute becomes more difficult. This, I guess, is a Nondeterministic Finite Automaton or State Machine. I don't really want to store states like "inactive\_broken" and "active\_missing\_outdated", etc.

The best I've come up with is to have both the "state" attribute and store some sort of superstate – "available" vs "unavailable", in this case – **and** each of the booleans. That way I could have a guard-like method when transitioning.

Has anyone else run into this problem and come up with a good solution to tracking states?