Back to blog
Architecture Next.js TypeScript SaaS Engineering Best Practices

The Code Patterns I Use, and When I Skip Them

By Ken B Portfolio · Published on October 29, 2026
Illustration of a developer working at a laptop

An app that gets slower to change every month usually has a structure problem. Either too little: everything is tangled, so one fix breaks three other things. Or too much: patterns built for large companies, so a small change touches six files.

Software has a lot of named patterns. SOLID, DRY, Clean Architecture, 12-Factor. Each one solves a real problem. Each one also has a cost: extra files, extra steps and slower changes, paid for nothing where the problem does not exist.

So I do not apply them all, everywhere. My rule of thumb: a pattern has to fix a problem I have now, or one I can see coming soon. Each pattern, in detail, is in the Technical tab.

A real case: a rule that only lived in a doc

In the job-alert app I build, each business area (billing, proposals, job alerts and so on) has one front door. Other code may only reach that area through one file. That keeps each area’s insides private, so I can change them without breaking the rest of the app.

The rule was written down. But AI tools take whichever shortcut is closest. An audit in October 2026 counted 323 shortcuts past those front doors, in 160 files. Nothing was broken yet. Each shortcut was a spot where a change in one area could quietly break another.

Now other code goes through the front doors, and a test fails on any new shortcut. The same work found 2 saves that skipped their checks. One could reset a member’s saved settings to defaults if two saves landed at once. Both are fixed.

The lesson: a structure rule only holds if something checks it. A doc is not enough when AI writes the code.

What I add at each stage

StageWhat I add
MVPThe rules I never skip (below), one folder per business area, settings kept out of the code. Little else.
Before launchA thin wrapper around payments, logins and AI, so each outside service can be swapped in one place. A separate test environment and database.
In production, making moneyA full 12-Factor review, and wrappers on every outside service.

In my job-alert app, the payment service is used from one file in the whole app. If the AI provider fails, a second one takes over, and no other code needs to know.

The rules I never skip

Everything above depends on the app and its stage. These do not. They are part of my 15 architecture rules, and they apply on day one:

  • Check every input at the edge. Forms, API calls, AI answers, data from the database. Never trust a shape you did not check.
  • Keep three shapes apart. What the database stores, what the business logic uses, and what the API sends back. A database change should not break the screen.
  • Every update and delete checks ownership. The query itself confirms the row belongs to this user. Not an earlier check that could be stale.
  • Read-then-write runs in a locked transaction. Two clicks at once must not create two records or spend one credit twice.

These are the ones that cost real money and real user trust when they go wrong. AI tools skip them often, which is why my PR review skill checks them on every change.

Four questions to ask your developer

  1. Where does the billing code live? Listen for one place, not “all over”.
  2. If we switch payment or email provider, how many files change? One or a few is a good answer.
  3. Which patterns are you skipping for now, and why? A good answer names one and the problem it would solve later.
  4. What stops AI from taking shortcuts past the structure? A test, not a doc.

You don’t need to know any of these pattern names. I pick the ones that fit your stage, skip the rest, and tell you in plain words what each one buys you.

The short version

The patterns are tools. Each one fixes one problem and costs extra work everywhere else. Add a pattern when its problem shows up, keep the safety rules from day one, and back every structure rule with a test, not a doc.

Which problem does your app have today: bugs that come back, slow changes, or code nobody wants to touch?

CODETHATSTAYSEASYTOCHANGE

Tell me about your app and I'll tell you which of these it needs now, and which can wait.

More Posts

All posts