Archive for June, 2013

The enumerated type for PHP

Enum

Whenever a procedure accepts a limited set of variables one could use an enumeration. Enumerations make for clearer and more readable code, particularly when meaningful names are used. A page at MSDN states the benefits of using an enumeration include:

  • reduction of errors caused by transposing or mistyping numbers,
  • simplify changing values in the future,
  • code is easier to read, which means it is less likely that errors will creep into it and/or
  • ensuring forward compatibility. With enumerations, your code is less likely to fail if in the future someone changes the values corresponding to the member names.

Enumerations are a must if your software solution spans across multiple projects and/or if the team you work is rather large. Read the rest of this entry »

1 Comment