On Formatting Code

Karan Chawla / April 16, 2021

1 min read

The coding style and readability set precedents that continue to affect maintainability and extensibility long after the original code has been changed beyond recognition. Your style and discipline survives, even though your code does not.

Concepts that closely related should be kept vertically close to each other.

Variables should be declared as close to their usage as possible. Because our functions are very short, local variables should appear at the top of each function.

If one function calls another, they should be vertically close, and the caller should be above the callee, if at all possible.

Subscribe to the newsletter

Get emails from me about future of technology, philosophy, and human behavior.

- subscribers