4 min readJust now
β
As software engineers, we often ask ourselves: how do we write scalable code? But more often than not, what we really mean is: how can we write code that leads to scalable, performant systems? This post is **not **about answering that question. For some thoughts on that topic, check out my other post. Instead, weβll take a brief look at a different, more literal interpretation of this question. How do we write code that is itself scalable, and why is that important? Scalable code lasts the test of time and changing hands of hundreds or even thousands of people with evolving requirements. Iβve been fortunate to have the experience that started with a handful of engineers and has grown to hunβ¦
4 min readJust now
β
As software engineers, we often ask ourselves: how do we write scalable code? But more often than not, what we really mean is: how can we write code that leads to scalable, performant systems? This post is **not **about answering that question. For some thoughts on that topic, check out my other post. Instead, weβll take a brief look at a different, more literal interpretation of this question. How do we write code that is itself scalable, and why is that important? Scalable code lasts the test of time and changing hands of hundreds or even thousands of people with evolving requirements. Iβve been fortunate to have the experience that started with a handful of engineers and has grown to hundreds today. Iβve been able to see firsthand the necessity of scalable code and how tricky things can become when it is not. Weβll explore why this matters and why we need to broaden our perspective on software engineering to include time, people, and risk. Weβll also have some fun little AI-generated ASCII diagrams to help visualize the points.
If you want a great resource on more of the how of this topic, I highly recommend checking out Dave Cheneyβs tips on writing great Go code: https://dave.cheney.net/practical-go. Although written for Go, the principles can be taken to any language.
Growing Audiences
No one is going to understand the code you write better than yourself, especially when itβs fresh. But unless you are working entirely alone or on a personal side project, your codeβs audience will be much larger than you think. I like to think of the audience or reader of your code as: your present and future self, your coworkers today and in the future, other systems and machines, and now AI. All of these readers need to be able to understand and reason about your code. The easier it is for them to understand, the more productive the team will be, and the fewer bugs will occur due to incorrect assumptions or misunderstandings. If you are more visual, check out this ASCII diagram:
AUDIENCES βββββββββββββββββββ β YOUR CODE β βββββββββββ¬ββββββββ β βββββββββββΌββββββββββ β β β βΌ βΌ βΌ βββββββββββ βββββββββββ βββββββββββ β HUMANS β β FUTURE β β AI β β β β YOU β β β β β’ Teams β β β β β’ LLMs β β β’ Internsβ β β’ 6mo β β β’ Tools β β β’ Reviewsβ β β’ 2yr β β β’ Analysisβ βββββββββββ βββββββββββ βββββββββββ β β β βΌ βΌ βΌ Need: Need: Need: Clarity Context Structure Names Comments Patterns Flow History Consistency
Exponential Risk & Complexity
In a growing organization, the complexity and associated risks grow exponentially. This is due to the number of times a piece of code changes hands multiplied over time. Check out the ASCII diagram below for a more visual interpretation of this point:
Exponential Risk/Complexity growth:Time β T0 T1 T2 T3 βββββ βββββββββββ βββββββββββββββββ βββββββββββββββββββββββ β 1 β β 4 β β 16 β β 64+ β βββββ βββββββββββ βββββββββββββββββ βββββββββββββββββββββββT0: Initial Change βββββββββββββββ β Code Change β β Single developer, single file βββββββββββββββT1: First Usage Tree (4 people) βββββββββββββββ β Code Change β ββββββββ¬βββββββ β ββββββββ΄βββββββ β β Dev A Dev B β β ββββΌβββ ββββΌβββ βCopy β βAdaptβ β Different interpretations βββββββ βββββββT2: Ripple Effect (16+ people) βββββββββββββββ β Code Change β ββββββββ¬βββββββ β ββββββββ΄βββββββ β ASSUMPTIONS β β Interface assumptions solidify ββββββββ¬βββββββ β ββββββββΌβββββββΌβββββββΌβββββββ β β β β β TeamA TeamB TeamC TeamD Vendor β β β β β βββΌββ βββΌββ βββΌββ βββΌββ βββΌββ β ? β β ? β β ? β β ? β β ? β β Each creates their own interpretation βββββ βββββ βββββ βββββ βββββ β β β β β βΌ βΌ βΌ βΌ βΌ More More More More More Code Code Code Code CodeT3: BLAST RADIUS (64+ exponential growth) βββββββββββββββββββββββββββββββββββββββββββββββββββ β π₯ EXPLOSION π₯ β β βββββββ βββββββ βββββββ βββββββ βββββββ β β βProd β βAPIs β βLibs β βDocs β βTestsβ β β βββββββ βββββββ βββββββ βββββββ βββββββ β β β² β² β² β² β² β β ββββ΄βββ ββββ΄βββ ββββ΄βββ ββββ΄βββ ββββ΄βββ β β β ? ? β β ? ? β β ? ? β β ? ? β β ? ? β β β βββββββ βββββββ βββββββ βββββββ βββββββ β β β β π΄ Bug becomes "Feature" (too late to fix) β βββββββββββββββββββββββββββββββββββββββββββββββββββ
Without scalable code, every new engineer multiplies the risk instead of distributing it.
Intern Rule
This is more of a βhowβ point, but I felt I should share it either way. A good rule of thumb I always try to keep in mind when writing code is what I like to call the βintern rule.β Essentially, all this means is that five years from now, when an intern reads your code, they should be able to understand it. You should never assume your code is βself-explanatoryβ and instead make sure itβs clear and very well documented. Like the other sections, here is your AI-generated ASCII diagram:
INTERN RULEYear 0: You Write It Year 5: Intern Inherits Itβββββββββββββββββββ ββββββββββββββββββββββββββββ β β ββ π§ = 100% β β β π§ = 5% ββ β β ββ β’ Full Context β β β’ No Context ββ β’ Your Patterns β β β’ Different Background ββ β’ Your Domain β β β’ Time Pressure ββ β’ Your Style β β β’ Learning Mode ββββββββββββββββββββ βββββββββββββββββββββββββββ β β βΌ βΌβββββββββββββββββββ ββββββββββββββββββββββββββββ Can you write β β Can they understand, ββ code that β β modify, and extend ββ survives this β ? β your code without you? ββ transition? β β ββββββββββββββββββββ βββββββββββββββββββββββββββ
Scalable code is far more than just worrying about performance. Itβs about the longevity of your code. Itβs code that survives people, time, and chaos. If your code is easy to understand and contribute to years from now, you can be confident youβve written something that can truly scale.