Should programmers use boolean variables to “document” their code?

Splitting an expression that’s too nested and complicated into simpler sub-expressions assigned to local variables, then put together again, is quite a common and popular technique — quite independently of whether the sub-expressions and/or the overall expression are boolean or of just about any other type. With well-chosen names, a tasteful decomposition of this kind can increase readability, and a good compiler should have no trouble generating code that’s equivalent to the original, complicated expression.

Some languages that don’t have the concept of “assignment” per se, such as Haskell, even introduce specialized constructs to let you use the “give a name to a subexpression” technique (the where clause in Haskell) — seems to bespeak some popularity for the technique in question!-)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)