2024 #4 Newsletter

Never use magic numbers in your code: Do this instead

Coding puzzle

Can you solve this coding puzzle?

Featured content

Coding as a logical unity of beauty and elegance

Imagine a game of chess.

Each piece, while powerful in its own right, finds its true potential when working in harmony with the others. Knights flank, pawns push, and rooks guard, united in their pursuit of checkmate.

a screenshot of a chess game on a cell phone

In the same way code exists not as a collection of isolated lines, but as a symphony of components, each playing its part in the grand composition of the program.

Object-Oriented Programming (OOP) embodies this principle of unity; by encapsulating data and functionality within objects, OOP creates self-contained units that interact and collaborate.

Never use magic numbers in your code: Do this instead

Can you guess what this does? 👇

We have no idea what those numbers and variables mean in the bigger picture of the codebase.

It’s a mystery. It’s magic to everyone apart from the developer who wrote the code.

We can’t possibly make any contributions to this code; we’re stuck.

But what if our dev had looked beyond code that merely works and also focused on communicating the full story of the code?

At the very least they would have given those variables far more descriptive names to explain the context:

Facebook icon
Twitter icon
LinkedIn icon

Logo