Complementary Names

When creating MeaningfulNames for concepts or operations that are closely related to one another, it is a good idea to use strongly related names. This is especially true when one of the operations is the opposite or complement of the other. Some examples of good complementary names are:

Unfortunately, many common complementary terms used by computer programmers and computer users do not follow this rule. For example, get and set are not complements anywhere but in program source code. The opposite of get should be something like give or lose. Put is close, but is still not what a non-programmer would tell you is the opposite of get. Set seems to have many complementary terms, including get, reset, and clear.

Some bad name choices involve mixing uncomplementary words. Many programmers will write code where they "open" a file but then "dispose" of the handle when finished, or "lock" something and then "release" it later, or "get" input but then "write" output. This causes unnecessary confusion for readers of the code.

Some other examples of bad complementary pairs that we have to live with are:

Some would argue that these are all technical terms, with technical definitions, and that any non-technical connotations or obscure relationships between the terms are irrelevant. Experienced programmers know what they mean. The "bad" pairs described above are well-established, so there is no need to start a crusade to eradicate them. Just think about these examples when you are creating new names for things, and avoid creating sets of names that belong on this list.

The situation is bad when programmers create it for themselves, but it is even worse is when such jargon makes it into the user interface or user manual, leaving a nontechnical user to try to figure out the relationship between two terms that are seemingly unrelated, or which seem synonymous. Here are some examples:

Problems also arise through lack of any complementary term for a given term. For example, a video game's settings may include a checkbox labeled "Enable 16-bit textures". It is not clear to the user what it means to leave this box unchecked: does it use no textures at all, or 8-bit textures, or 32-bit textures, or something else entirely?


See also NameByContrast, SystemOfNames


CategoryCodingIssues CategoryNaming


EditText of this page (last edited October 25, 2009) or FindPage with title or text search