Friday, April 24, 2009

Use positive expressions

When striving for clear and concise articulation, in programming or in natural languages, try to express yourself with as few negations as possible. Negations leed to confusion. Our brain does not handle them well.

Example 1: It is better to ask "may I sit here?" than "is this seat taken?". Try it. The latter question will confuse some people. They might answer "no" even though the seat is taken and vice versa, especially if you mumble and all they understand is your intention to take that seat. Their brain translates the question to "should I allow the guy to take that seat?".

Example 2: if a newspaper writes "Senator Smith never smoked pot", the number of people thinking that Senator Smith smoked pot might grow because all they might remember is "senator smith" and "pot". Negative associations rarely work.

When programming, it is essential to write clear and understandable code. Avoiding the not operator helps.
  • It is better to write "if x==7 then a else b" than "if x!=7 then b else a".
  • It is also better to create a method "list.hasItems" than "list.isEmpty".
  • It is better to have a checkbox that says "cache thumbnails" and is enabled by default than a checkbox "do not cache thumbnails" that is disabled by default (as found in the folder options of Windows).
You get the idea. Internalize it.