Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Programming Best Practices

Here are few things TODO no matter what programming language you use.

White Space Hygiene

Configure your IDE to

My vscode config

Width Guides

I try to limit my code width to 80 columns. In vscode I use a ruler to provide such a guide.

My vscode config

Sizing Your Functions

If the function does not fit on your screen - it is too big.

Naming Best Practices

Mixing Cases

No matter which convention you use (snake_case, kebab-case, dromedaryCase / CamelCase) - make sure to stick to it.

Choosing Case

Have class name capitalized. Methods start with a lower case letter.

Functional Brackets

There are established 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:


In contrast, this would alarm me:


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.

Watch Your Constructor / Initializer

Constructor (initializer in python) does not return value and just initializes the space allocated for the object. Therefore, in its body, do NOT perform any action that may fail. You can still raise an exception though.

Design Best Practices

Design Patterns

Learn these, study these, love these.

Mind Your Complexity

Programming complexity can be reduced if you follow these rules of thumbs:


foo --calls--> bar --calls--> baz


foo --calls--> bar
foo --calls--> baz

Payload Format

On the wire use JSON or Protocol Buffers.

Do not use XML.

Configuration Storage

The way we store configuration is subject to fashion and is heavily influenced by the operating environment and/or cloud provider. Here are some reasonable candidates:

JSON is barely suitable - use YAML instead.

Secrets - Storage and Passing

Store these in the cloud. Secrets should not be hitting the disk or passed on the command line. You CAN pass secrets via environment variables. Better yet stdin or a cloud provider’s API.