The Readable Programming Language - Handbook

Enumerations

Definition

Enumerations are usually defined by a "is one of" sentence, and used as a type for attributes.
A gender is one of: - "female", - "male", - "I'd rather not say". Every user has a gender.

All values must be defined in one sentence.
It is not allowed to repeat a value.

Anonymous enumerations

It is also possible to define anonymous or inline enumerations when defining an attribute:
Every user has a current_activity, which is one of: - "chatting with friends", - "looking for new friends", - "away from computer", - "just looking".
Here "current_activity" is the name of the attribute, not its type. The type of the attribute is an anonymous enumeration with 4 possible values.

Enumerated attributes with multiple values

It is possible to make lists of enumeration values.
Every user has a list of genders called his friend_genders.

User interface

Single value enumerated attributes are edited with a dropdown-menu (HTML select).

Multiple value enumerated attributes are edited with a series of checkboxes.

Numbering

Defining each value of an enumeration with a numeric prefix allows to sort them and to compare them with numbers.
Each submission has a status, which is one of: - "10 in definition", - "20 in review", - "30 in correction", - "40 in review after correction", - "50 accepted". Each submission knows a reviewer, which is a user. On the "View Submission" page, if the given submission's status is greater than 20, the user can see its reviewer's username.