Type-safe enumerations
Often there is the necessity to define functionality based on a set of
values. If you have experience in C, you may have seen typedef enum {
WHITE, BLACK, YELLOW } color_t; before. In PHP, one could write
something like define('WHITE', 0); and define('BLACK', 1);
which is pretty much what the C version does. The problem with these approaches
are that they are not type-safe, and functionality needs to be attached by
using switch or if-else cascades. Further reading
Here's some more information on enums in the XP framework: From our blog
HistoryEnums were first introduced in July 2007 within RFC 0132. | Table of contents |