[pattern] PHP Interface constants [if used wisely]


There is much debate (see external links) about whether or not one should use constants in an interface.

My opinion is that in PHP it makes good sense to use an interface to encapsulate certain kinds of constants (especially ones that are not likely to change often), and so it is recorded here as a pattern, not an anti-pattern. The tutorial module OOE = Object Oriented Examples = One Of Each makes heavy use of PHP interface constants to promote Don't Repeat Yourself (DRY Principle) coding and avoid Write Everything Twice (WET) (because "we enjoy typing") coding.

Visit also