My Programming Principles in 2020

Abstract

This is rough brain dump of several principles/ideas that I applied in 2020 while working at Uber.

The fact that the code runs and does what you want means very little

Correctness composes

Let tests tell you how complex your code is

Try to not couple tests to logic that is not the subject of the test

Some test inputs shall remain fully abstract

There are kinds of responsibilities

There are kinds of data

Arrows shall flow in a single direction

Immutability changes everything

Data or logic; not both

Rich data reifies meaning, but is interpretation-free

Plain data = pure interface

Think in terms of types and transformations

Added meaning = changed type

Organize code in domain packages

‘Code reuse’ considered harmful

‘Everything is an X’ considered harmful

‘Mappers’ considered harmful

Java Builders considered harmful

null considered harmful

‘Automappers’ considered harmful

‘Anti-boilerplate’ sometimes considered harmful

Mind your layers

Mind your public API surface

Unmockable + reused = double-testing & test breakage

If error handling is not required, it will be skipped

Algebraic Data Types are not great; they’re necessary

(Tip) Use ADTs in your public API to remain open to extension

Build ‘Pits of Success’

Incorrect code should not compile

One public method

Static > Dynamic

Avoid inheritance

Be wary of dynamic business-level higher-order inputs & outputs

(Proto idea) Structural equality only