How I managed to encounter and recover from Computer Science’s Two Hardest Problems

Problem Background

Problem 1: Naming Things

Naming Issue 1

  1. Having a fully functioning testing suite would have been ideal as this problem would have been caught by CI and any future issues would have been caught.
  2. Using clearly named functions is important. reset and first have different meanings to me, but to a seasoned PHP developer, these are synonymous. Regardless, to make entry into a codebase easier, comments on lines with ambiguously named functions is a must.

Naming Issue 2

$query = $query->where('relationBId', $relationBId);
$result = _::filter($result, function ($item) use ($relationBId) {
return $item->relationBId === $relationBId;

Problem 2: Cache Invalidation

  • Thursday 4PM: Deploy the cached version with the missing _::first call
  • Thursday 4:30PM: Rollback the previous change
  • Friday 9AM: Deploy the fix with the _::first
  • Friday 9:30AM: Rollback the previous change
  • Friday 9:45AM: Deploy the final fixed version
  1. Whenever you have to rollback a deployed cache, you must bust it on the next deploy.
  2. A safer strategy for deploying caches is to do 2 stage deploys. In stage one, you deploy the cache write. In stage two, you enable the cache reads. This allows you to rollback the deploy cache reads without rolling back the cache writing mechanism which avoids this problem holistically. This solution took some extra code to accomplish but was well worth the effort of implementation.

Learnings & Takeaways Summary


Name variables better

Bust caches when redeploying a cache

Single Responsibility Functions

Write Unit Tests




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store