Skip to main content Link Menu Expand (external link) Copy Copied

Let the compiler tell you the story

A sufficiently structured codebase will guide you in how to implement new features. But only if you have a strongly typed language[^1].

Stop relying on your own brain to remember things

Using the same conditional checks in if statements throughout the code (e.g.: if(x.getType() == Y), will force the programmer to know all possible locations where this might be relevant, check and perhaps alter all of them.

An if statement always represents a different behaviour. A different behaviour usually has an associated name or term. These two together means that adding a class and using a design pattern (often a strategy) will help you the moment you add functionality:

  • a new method will break a subclass if it doesn’t have that method
  • a new implementation will break if it doesn’t adhere to the interface

This means that the compiler will do most error checking for you, and you don’t have to hunt for call-sites of this (perhaps hidden) abstraction.

(work in progress)

[^1] Weakly typed languages moves checking for completeness to the runtime where it may lie dormant for a long time until it is used. While strongly typed languages support your story at compile time.