The article emphasizes the advantages of using enumerations (enums) over booleans in programming, particularly in scenarios where future changes may occur. It illustrates this point by highlighting a potential system for beverage sizes, explaining how using a boolean can complicate future modifications. By opting for enums, developers can create more readable and maintainable code that is not only clearer for current users but also less prone to future pitfalls as system requirements evolve.
Booleans are a trap for future complexity. An advantage of enums is they are expandable... adding another drink size becomes much easier.
That call reads like documentation. It's clear and to the point, and the maintainer can see immediately what the call does and what the parameters mean.
Collection
[
|
...
]