Chapter 3: WHAT’S IN A NAME?
- Learn to name things transparently—an object’s name should describe it clearly.
- The key to good naming is to understand exactly what you’re naming. Only then can you give a meaningful name. If you can’t invent a good name for something, do you really know what it is, or even if it should exist at all?
- When naming, favor clarity over brevity.
- Name things well the first time, all the time.
- Meaningful function names avoid the words be, do, and perform. These are classic traps for beginners trying to consciously include verbs (this function does XXX . . . ). They are just noise and don’t add any value to the name.
- Name functions from an external viewpoint, with a doing phrase. Describe the logical operation, not the implementation.
- Avoid redundant words in names. Specifically, avoid these words in type names: class, data, object, and type.
- Choose a consistent naming convention—and use it consistently.
Jun 14, 2010
comments powered by Disqus