Last updated on August 16, 2020

Coding

👋 Hello! Most of these notes are "knowledge in the making", so parts of them could be incomplete 🙈, inaccurate 🙉 or even potentially wrong 🙊.

The Wrong Abstraction

When coding, we sometimes find ourselves having to work with a certain abstraction which made sense when it was first introduced, but if we were to extend it, it could be pushing its purpose a bit too much–we could end up with the wrong abstraction.

In these cases, Sandi Metz suggests:

When dealing with the wrong abstraction, the fastest way forward is back. Do the following:

  1. Re-introduce duplication by inlining the abstracted code back into every caller.
  2. Within each caller, use the parameters being passed to determine the subset of the inlined code that this specific caller executes.
  3. Delete the bits that aren't needed for this particular caller.

Sandi Metz

Function Size

A function does one thing if you cannot meaningfully extract another function out of it.

Robert C. Martin ("Uncle Bob")