Positive identifier

From HaskellWiki
Jump to navigation Jump to search

When choosing identifiers for Bool variables avoid negative namings! Arrgh, no! In order to start this lesson properly, let's formulate it the positive way: Please use positive identifiers! Why? Is it just another instance of the 'think positive' way of live? No! It's simply that boolean variables can have value False and in this case it is more mental effort to find out its meaning. Consider what skipIntro=False or omitRules=False may mean. Admittedly, after a bit of thinking you find it out. But compare it with the positive formulation and you will see, that this is really easier to understand:

skipIntro=False       -> performIntro=True
omitRules=False       -> includeRules=True
suppressWarning=False -> showWarning=True

The same applies to checkmarks in GUIs. Sometimes GUI designers seem to like to name the checkmarks in a way that the default mark status is 'deselected'. I think it is much better to name a checkmark such that the base case is associated with 'deselected' and 'selected' is reserved for switching a feature on, also if the default is that the feature is on.

See also