Benjamin Cane
Portrait of Benjamin Cane
Benjamin Cane
November 7, 2025

A dangerous mindset I’ve seen—and been guilty of—is assuming code doesn't change.

Or when it changes, the next person will understand the original context.

Reality check, they wont.

The next person (future you) has no idea what you were thinking.

🔎 A Simple Example:

You are building a service that receives JSON requests.

You write a method that takes in an array from the request and accesses index 2.

The request handler has already validated the array length and content.

So you don't need to recheck it before accessing index two, right?

It's just less efficient to check it twice, right?

Wrong.

Your original implementation might work fine, but fast forward to years later, when someone else (perhaps yourself) uses that method.

Will they always ensure the array has the right length? 🤷‍♂️

If they don't, your method is a ticking time bomb.

🧠 Fix the Mindset:

Embrace defensive programming, where you expect that your methods will be misused.

Recheck the array's length before you use it, even if something else has previously checked.

Expect bad inputs, expect errors to occur, and have a path to do something about it.

💡 Expect the Unexpected

If you assume the following person:

  • Won't read your docs or code comments
  • Will reuse your code in a different context
  • Will misuse your code for things you've never designed it for

You will write safer, more resilient code.

Back to the feed

Next Post

  • November 14, 2025 A common issue I see when teams first adopt gRPC is managing persistent connections, especially during failovers.

Previous Posts

  • October 31, 2025 ⚡️Does saving 1 millisecond really matter? Answer: more than you’d think.
  • October 27, 2025 Have you heard of Store and Forward? It’s a resiliency design prevalent in card & bank payments, telecommunications, and other industries.
  • October 24, 2025 When Building Low-Latency, High-Scale Systems, Push as Much Processing as Possible to Later

Made with Eleventy and a dash of #Bengineering energy.