How to write unreadable code: Put all code in one giant function


How to write unreadable code:

Put all code in one giant function.

Use short, unclear names.

Embrace deep indentation. Require the reader to hold dozens of pieces of state in their head at once.

Avoid proven libraries. Write everything yourself.

Skip tests.
How to write readable code:

Decompose the problem so pieces can be understood in isolation.

Use clear names.

Avoid excessive indentation. Return early. Extract functions.

Write mostly pure functions.

Use proven libraries so there’s less core to write and read.

Write tests.

View original on X