Engineering essentials
The core craft: estimating honestly, designing with patterns, everyday best practices, and the anti-patterns to avoid.
Software estimation
Open topicThe cone of uncertainty, the difference between estimates, targets and commitments, and the habits that make estimates useful.
The most common estimation techniques, when to use each, and an interactive PERT calculator.
Use your team's real throughput to forecast delivery dates with probabilities, and try it yourself.
AI makes coding faster, but estimates don't shrink the way you'd expect. Here's how to adjust.
Scripts and habits for talking about uncertainty with managers, stakeholders and customers.
Design patterns (GoF)
Open the catalogCreate whole families of related objects through one interface, so code never mixes parts from different families.
Assemble a complex object step by step with readable calls, check the rules once at the end, and get back a finished, valid object.
Let a base class run a workflow but leave one step, creating an object, to subclasses that decide which class it is.
Create new objects by copying a configured example, instead of building each one from scratch.
Make sure a class has exactly one instance and give the whole program one way to reach it. Useful, and the most overused pattern.
Wrap an existing class whose interface doesn't fit, so it works with code that expects a different interface.
Split something that varies in two ways into two separate class hierarchies, joined by a reference, so each side can grow on its own.
Build tree structures where single items and groups share one interface, so code can treat a whole group exactly like one item.
Wrap an object in another object with the same interface to add behaviour, such as caching, logging or retries, without changing the original.
Give a complicated subsystem one simple front door, so most callers can use it without knowing how its parts fit together.
Share the common, unchanging part of many similar objects instead of copying it into each one, to save memory at scale.
Put a stand-in with the same interface in front of an object to control access to it: check permissions, create it lazily, or reach it remotely.
Pass a request along a chain of handlers; each one either handles it or hands it to the next, so the sender doesn't need to know who deals with it.
Turn a request into an object with everything needed to run it, so you can queue it, log it, retry it or undo it.
Represent each rule of a small language as a class, build sentences as trees of those objects, and evaluate the tree to get an answer.
Walk through the items of a collection one at a time without exposing how the collection is stored, whether it's an array, a tree or a paginated API.
Make objects talk through one coordinator instead of directly to each other, so the rules about who affects whom live in one place.
Capture an object's state in a snapshot so you can restore it later, without exposing the object's internals to whoever keeps the snapshots.
Let objects subscribe to another object's changes, so it can notify all of them without knowing who they are.
Let an object change its behaviour when its internal state changes, with one class per state instead of status checks in every method.
Put each variant of an algorithm in its own class behind one interface, so callers can swap behaviour without changing their code.
Write the skeleton of an algorithm once in a base class, and let subclasses fill in only the steps that differ.
Add new operations to a fixed set of classes without changing them, by putting each operation in its own visitor object.
Cloud patterns
Open the catalogGive each dependency or workload its own limited pool of resources, so one slow part can't use up everything and sink the whole service.
Stop calling a dependency that keeps failing, fail fast with a fallback, and probe now and then to see if it has recovered.
Expose an endpoint that reports whether an instance can do its job, so load balancers, orchestrators and monitors can route around problems.
Automatically try a failed call again after a growing, randomised delay, because many cloud failures are brief and fix themselves.
Cap how many requests each client can make in a time window, and reject the excess politely, to protect your service and keep it fair.
Put a translation layer between a new system and a legacy or external one, so the old system's model and quirks don't leak into the new design.
Let several identical workers read from the same queue, each message going to exactly one of them, so processing scales out simply by adding workers.
Publish an event once to a topic and let any number of independent services subscribe to it, without the publisher knowing who they are.
Put a queue between a spiky source of work and the service that does it, so bursts are absorbed and processed at a steady, safe rate.
Run a business transaction across several services as a series of local steps, each with a compensating action that undoes it if a later step fails.
Save a change and the event announcing it in the same database transaction, then publish the event separately, so you never lose or invent events.
Check a fast cache first, load from the database only on a miss, and store the result in the cache for next time.
Use one model to change data and a separate, read-optimised model to query it, so each side can be designed and scaled for its own job.
Store every change as an immutable event in an append-only log, and derive the current state by replaying them, instead of overwriting rows.
Precompute the data a screen or report needs into a ready-made table, and keep it updated, instead of joining and aggregating on every request.
Split one big data set across several databases by a key, such as customer or region, so data and load can grow beyond what one server can handle.
Put a local helper between an app and the remote services it calls, to handle retries, timeouts, routing and credentials on the app's behalf.
Give clients one entry point that routes requests to the right backend service and handles shared concerns like authentication and rate limits.
Give each kind of client, such as web, mobile or partners, its own thin backend that shapes data exactly for that client.
Let a group of identical instances pick one leader to do work that must happen exactly once, and automatically pick a new one if it fails.
Run supporting features such as proxying, logging or config sync in a separate container next to the app, sharing its lifecycle but not its code.
Serve files that are the same for everyone, such as scripts, styles, images and prerendered pages, from object storage behind a CDN instead of from app servers.
Replace a legacy system piece by piece behind a routing layer, sending more features to the new system over time until the old one can be switched off.
Hand clients a short-lived, narrowly scoped token so they can upload or download files directly from storage, without streaming through your servers.
Architecture & AI patterns
Open the catalogStructure a system around events: components announce what happened, and other components react, instead of calling each other directly.
Put the business logic at the centre with no dependencies on frameworks or databases; everything else plugs in through ports and adapters.
Organise an application into horizontal layers (presentation, business logic, data access) where each layer only talks to the one below it.
Build a system as small, independently deployable services, each owning one business capability and its own data, run by one team.
One deployable application split internally into modules by business capability, each with its own code, data and public interface.
Let a language model work in a loop: decide the next action, call a tool, look at the result, and repeat until the goal is reached.
One model call produces a draft, another evaluates it against clear criteria, and the draft is revised until it passes or a limit is reached.
Check what goes into and comes out of a language model with separate, independent rules, so unsafe input and bad output are stopped before they cause harm.
Break a task into fixed steps, each a focused model call whose output feeds the next, with ordinary code checking results in between.
Before asking a language model to answer, look up the most relevant passages from your own documents and give them to the model as context.
Data structures
Open the catalogValues stored side by side in one block of memory that grows by doubling: O(1) access by index and amortized O(1) appends.
A chain of nodes where each holds a value and a pointer to the next: O(1) inserts and removals at known positions, O(n) to find anything.
A queue adds at the back and removes from the front, first in, first out; a deque does both at either end. All in O(1).
A fixed-size array whose read and write positions wrap around the end, giving an O(1) queue with no allocation: ideal for streams, logs and recent history.
A last-in, first-out collection: push onto the top, pop from the top, both O(1). Behind function calls, undo, parsing and depth-first search.
A compact bit array that answers "definitely not present" or "probably present" using several hash functions: tiny memory, no false negatives.
Store key–value pairs in an array of buckets chosen by a hash of the key, so lookups, inserts and deletes take constant time on average.
A fixed-size cache that evicts the least recently used item, built from a hash table plus a doubly linked list so every operation is O(1).
Binary search trees that rebalance themselves with rotations, guaranteeing O(log n) search, insert and delete whatever order keys arrive in.
A complete binary tree stored in an array where every parent is smaller than its children, giving the minimum in O(1) and inserts and removals in O(log n).
A binary tree where every left subtree holds smaller keys and every right subtree larger ones: O(log n) search, insert and ordered traversal when balanced.
A tree of characters where each path from the root spells a key, so prefix searches like autocomplete take time proportional to the prefix, not the dataset.
A set of vertices connected by edges, stored as an adjacency list or matrix: the structure behind maps, networks, dependencies and recommendations.
Track which items belong to the same group as groups merge: near-constant-time union and find with path compression and union by rank.
Algorithms
Open the catalogFind a value in a sorted array by repeatedly halving the range that could contain it: at most about 20 comparisons for a million items.
Keep a contiguous range that grows on the right and shrinks on the left, updating a running result as it moves, to solve substring and subarray problems in O(n).
Walk two indexes through an array, often from both ends towards the middle, to solve pair and partition problems in one O(n) pass instead of O(n²).
Explore a graph level by level from a start vertex using a queue, finding the shortest path in number of edges to everything reachable.
Explore a graph by going as deep as possible along each path before backtracking: the basis of cycle detection, topological sort and maze solving.
Find the cheapest path from one vertex to all others in a graph with non-negative edge weights, by always settling the closest unfinished vertex next.
Connect every vertex of a weighted graph using the cheapest possible set of edges, with no cycles: Kruskal's and Prim's greedy algorithms.
Order the vertices of a directed acyclic graph so every edge points forward: the order to run tasks, build packages or apply migrations so dependencies come first.
Split a problem into independent smaller parts, solve each recursively, and combine the answers: the idea behind merge sort, quicksort and binary search.
Solve problems with overlapping subproblems by computing each one once and reusing the answer, often by filling a table: edit distance, knapsack, routing.
Build a solution by always taking the choice that looks best right now, never reconsidering: fast and simple, and optimal only for problems with the right structure.
Solve a problem by solving smaller versions of itself; backtracking builds solutions one choice at a time and undoes choices that lead to dead ends.
Sorting algorithms
Open the catalogRepeatedly swap adjacent values that are out of order until a full pass makes no swaps: simple to understand, O(n²), and almost never the right choice.
Take each value and slide it left into its place among the already-sorted values: O(n²) in general, but very fast on small or nearly sorted arrays.
Find the smallest remaining value and swap it into place, one position at a time: always O(n²) comparisons, but at most n − 1 swaps.
Turn the array into a max-heap, then repeatedly move the largest value to the end: guaranteed O(n log n) with O(1) extra memory, but not stable.
Split the array in half, sort each half, then merge them: a guaranteed O(n log n), stable sort, and the basis for sorting data too big for memory.
Pick a pivot, partition the array into smaller and larger values around it, then sort each side the same way: O(n log n) on average, in place.
Count how many times each key value occurs, then write the values back in order: O(n + k) time for small integer keys, with no comparisons at all.
Sort integers digit by digit, from least to most significant, using a stable counting sort on each digit: O(d · n) for d-digit keys.
The merge sort and insertion sort hybrid behind Python, Java and V8's built-in sorts: stable, O(n log n), and very fast on partly ordered data.
Best practices
Open topicFive principles for code that is easy to change, each explained with a short example and a warning about overuse.
The small daily habits that make code easy to read, review and change.
How many tests of which kind, how to write tests that catch real bugs, and how AI changes testing.
How to make code reviews fast, kind and genuinely useful, including reviews of AI-generated code.
How continuous integration and delivery work, the practices that make them effective, and how to measure progress.
How to get high-quality results from AI pair programmers and agents, and stay the engineer in charge.
Anti-patterns
Open topicThe most common code-level anti-patterns, how to recognize them and how to refactor your way out.
The structural mistakes that make systems slow to change and painful to run, and how to recover.
The team and process traps that quietly destroy productivity and morale, and what healthy teams do instead.
The new failure modes of AI-assisted development, and the habits that prevent them.
Explainers
Why estimates go wrong (and how to fix them)
The cone of uncertainty, ranges instead of numbers, and forecasting with data.