10/15/2025

Software Quality

Why Small Abstractions Create Big Leverage in Engineering

There is a point in every engineer’s career where you start noticing patterns. You realise the hardest problems are rarely solved through massive rewrites. They are solved through small, thoughtful abstractions that quietly remove friction for the entire team.

When I was younger, I thought the important pull requests were the big flashy ones. Now I know the real leverage often comes from the tiny utilities, the predictable contracts, and the small improvements that spread across the whole system.

This is an example that completely changed how I think about engineering decisions.

Drawing

The problem of inconsistent errors

I once joined a project where every service returned errors in a different shape. A few examples looked like this:

{
  "message": "Something went wrong"
}
{
  "error": "Invalid token",
  "code": 401
}
{
  "detail": "User not found",
  "type": "NotFound"
}

Everything technically worked. But every response required a different mental model. The frontend had to guess which field to read. Debugging felt heavier. And onboarding new engineers meant teaching exceptions instead of patterns.

So we fixed it with a tiny abstraction.

The tiny fix that changed everything

We introduced a single shared error shape.

export type AppError = {
  message: string
  status: number
  details?: unknown
}

Then we added helpers on the backend:

export function makeError(
  message: string,
  status: number,
  details?: unknown
): AppError {
  return { message, status, details }
}

export function notFound(message = "Resource not found"): AppError {
  return makeError(message, 404)
}

export function badRequest(message = "Invalid request"): AppError {
  return makeError(message, 400)
}

The backend became more expressive:

if (!user) {
  return notFound("User does not exist")
}

if (!input.email) {
  return badRequest("Email is required")
}

The frontend became predictable:

async function fetchData(url: string) {
  const res = await fetch(url)
  const data = await res.json()

  if (!res.ok) {
    const err = data as AppError
    throw new Error(err.message)
  }

  return data
}

One small abstraction. Huge reduction in cognitive load.

The team moved faster. Reviews were clearer. Bugs became easier to trace. New engineers onboarded without confusion.

This was the moment I truly understood how small decisions can lift an entire engineering culture.

Code becomes easier when everything has a shape

Shape discipline creates clarity. Once you start noticing it, you see the value everywhere.

Here is a simple frontend example. I often see handlers like this:

const handleSubmit = () => {
  if (isLoading) return
  if (!user) return
  if (isError) return
  onSubmit()
}

It works. But it scales poorly.

A tiny state machine changes everything:

type FormState = "idle" | "submitting" | "error" | "success"
function canSubmit(state: FormState, user: User | null) {
  return state === "idle" && Boolean(user)
}

Your component becomes clearer:

if (canSubmit(formState, user)) {
  onSubmit()
}

Not clever. Just intentional. And intentional code lasts longer.

Abstractions are not for showing off

Something I learned early:

Clever abstractions impress people once. Useful abstractions help people every day.

The best abstractions do this:

They reduce repeated thinking. They remove guesswork. They clarify intent. They protect future contributors. They prevent bugs before they appear. They shrink the mental load of navigating the codebase.

They are often small. Sometimes boring. Always valuable.

Real leverage is invisible

Most people do not see the abstractions that make their work easier. They simply feel them.

A consistent error shape. A stable request pattern. A shared state machine. A clear folder structure. A tiny utility that replaces boilerplate.

None of these are glamorous. But they quietly raise the quality of everything built on top of them.

I used to think senior engineering meant solving dramatic challenges. Now I think senior engineering is the quiet ability to make the whole team’s life easier.

Small abstractions.
Big leverage.
Every time.