Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Naming Best Practices

Other best practices

Mixing Cases

Conventions:

Pick the right one (you decide what that means), stick to it.

Choosing Case

Most commonly used approach:

Functional Brackets

There are established (English) naming brackets:

Hence, if you have begin_foo make sure the end_foo is defined. Not finish_foo.

The above list is ordered by narrowing the scope. In other words, I find this logical:

o.init()
    o.start()
        o.push(123)
        o.pop()
    o.finish()
o.shut()

In contrast, this would alarm me:

o.push(123)
    o.start()
        o.init()
        o.finish()
    o.shut()
o.pop()

Naming Verbosity vs Scope

The smaller the scope of the identifier, the shorter it can be.

It is OK for a local variable to be called port, even p. A global variable holding the same should be descriptive, e.g. the_web_server_port.

Naming Specificity

When naming variables:

For example:

Watch Your Language: Noun vs Verb, Singular vs Plural

Be intentional about your language and use the nouns and verbs consistently, e.g.:

Naming Predicates

Predicate is a function returning boolean value with no side-effects.

Recognizers are predicates. Suppose you have class Car defined. What should you call a car recognizer? Here are few conventions to pick from:

DO use consistent names for predicates.