Last Revision — April 19, 2022
1 Min Read
---
Lexical Abusers
Names
Within a Class
- Uncommunicative Name (family)
- Magic Number (family)
- "What" Comments (causes)
Marcel Jerzyk in thesis (2022): "Code Smells: A Comprehensive Online Catalog and Taxonomy"
In the Haskell community, there is a well-(un)known question about the filter function - does the filter predicate means to TAKE
or to DROP
(check example)? Boolean Blindness smell occurs in a situation in which a function or method that operates on bool
-s destroys the information about what boolean represents. It would be much better to have an expressive equivalent of type boolean with appropriate names in these situations. For the filter function, it could be of type Keep
defined as Keep = Drop | Take
.
This smell is in the same family as Uncommunicative Names and Magic Numbers.
Neither in real life one can answer just yes/no without ever confusing interlocutor to every single closed question that may possible.
data Bool = False | True
filter :: (a -> Bool) -> [a] -> [a]
data Keep = Drop | Take
filter :: (a -> Keep) -> [a] -> [a]