[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Choosing good names for things is difficult (was: Strange Behavior)

Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

> On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote:
> > I invoked the wrong bug.py :/ , works fine now (this happens to me
> > when im a bit tired sometimes...).
> Clarity in naming is an excellent thing [?] Programs should be named
> by what they do [?] or when that isn't practical, at least give them a
> unique and memorable name [?].

It's worth noting, along with this useful admonition, that naming things
well is one of the most difficult things to do.

It is especially difficult in computer software, while also being rather
more important than the typical problem of naming, because of the
simultaneous constraints that the names within computer software should

* Memorable and evocative of the meaning to humans, who have a limited
  capacity for remembering large sets of different names exactly, but a
  high tolerance (even fondness) for multiple-meaning and ambiguous

  So, choosing unique names is difficult, and the set of memorable names
  is severely limited.

* Starkly unique and exact every time for the computer's use, without
  regard to meaning, and any name is just as memorable to a computer as
  any other.

  So, choosing unique meaningful names is crucially important in working
  with computer software.

That combination ? difficult but important to do well ? is a perennial
bugbear for programmers.

You can find many essays on the ?naming things is difficult? theme, with
the most concise and pithy being attributed to Phil Karlton (RIP) of
Netscape in the 1990s. Another wit takes that to its logical conclusion:

    A well known aphorism attributed to Phil Karlton is:

        There are only two hard things in Computer Science: cache
        invalidation and naming things.

    I realized yesterday that this is really only one hard problem: much
    of the reason that naming things is hard is that changing names is
    hard, so you'd better name something right the first time. Why is it
    hard to rename things? Poor cache invalidation.


 \              ?In the long run, the utility of all non-Free software |
  `\      approaches zero. All non-Free software is a dead end.? ?Mark |
_o__)                                                    Pilgrim, 2006 |
Ben Finney