Mastering Code: The Knobs of Success
The Pros Know the Fundamentals Better!
Weekly Edition
Three high‑impact topics (about 90 seconds each) to compound your growth. Plain English, vivid metaphors, practical moves.
1) Coupling & Cohesion: The Two Knobs That Shape Your Code
If software were a sound system, these are the two master dials. Turn cohesion up (each part does one clear job). Turn coupling down (parts don’t depend on each other’s guts). Most design wins are just better positions on these two knobs.
Why this compounds
- Fewer ripples: a change in one place doesn’t crack glass across the house.
- Faster onboarding: newcomers learn modules that tell one story instead of five.
- Cheaper testing: highly cohesive parts are easy to test; loosely coupled parts need fewer integration acrobatics.
Metaphor
- Restaurant kitchen: a “grill” station (high cohesion) that doesn’t need to know how “pastry” manages flour (low coupling) runs smoother than a kitchen where every chef shouts across the room.
How to do it
- Write a one‑sentence charter per module
- “Pricing calculates totals from items, taxes, and discounts—nothing else.” If your sentence needs “and then also…,” you’ve found stray responsibilities.
- Hide your wiring
- Expose tiny public surfaces (few functions, stable inputs/outputs). Keep everything else private. If others can’t touch it, they can’t depend on it.
- Pass data, not objects
- Share simple shapes (IDs, amounts, timestamps), not whole objects that smuggle in accidental dependencies.
- Remove cross‑talk
- Ban imports that reach into a neighbor’s internals. Communicate only through agreed interfaces.
- Measure with quick heuristics
- Files that often change together may belong together (cohesion). A change that forces edits in many places signals tight coupling—add a seam or an adapter.
Try this today
- Pick a “mystery box” module everyone fears. Write its one‑sentence charter, move anything off‑charter out, and shrink its public API by 25%.
Further reading
- “Cohesion and Coupling” overview (clear definitions and history). Wikipedia | Wikipedia
- Parnas on information hiding (classic paper). ACM TSE
2) Data Lineage: Always Know “Where Did This Number Come From?”
Bugs hurt less when you can trace a number’s family tree. Data lineage is simply keeping receipts: how a piece of data was created, transformed, and moved. When provenance is clear, audits are boring, debugging is fast, and trust goes up.
Why this compounds
- Faster root cause: you can walk backward from “we charged $0” to the exact step that zeroed a subtotal.
- Safer changes: transformations are visible, so you know which pipelines to update.
- Sharper accountability: every dataset has an owner and an origin, not a shrug.
Metaphor
- Parcel tracking: you don’t guess where your package is; you see “left warehouse → customs → out for delivery.” Give your data barcodes and scans at every hop.
How to do it
- Tag data at birth
- Assign a durable
event_idorsource_idthe moment information is created. Carry it through every transform.
- Assign a durable
- Log the hops
- For each pipeline step, log “input IDs, code version, timestamp, output IDs.” Keep logs queryable (structured, not free‑text).
- Version your transforms
- Name transformations and store their versions next to the code. “TaxCalc v3” leaves a breadcrumb in outputs.
- Keep a lineage map
- A lightweight graph: datasets as nodes, transforms as edges. Even a Markdown diagram beats guessing.
- Make it visible in the UI
- For critical numbers, add a “Why?” link that shows last hop, inputs, and code version. Transparency builds user trust.
Try this today
- Choose one high‑stakes metric (billing total, payout, quota). Add
calculation_id, record inputs and transform version, and create a one‑page lineage view for the last 50 calculations.
Further reading
- “Data lineage” concepts and approaches. Wikipedia
- OpenLineage (open standard for lineage metadata). OpenLineage
- “Martin Fowler: Event Sourcing” (useful for provenance thinking). martinfowler.com
3) Little’s Law for Dev Flow: Why Smaller Queues Win
You don’t need a gantt chart to improve throughput. Little’s Law says: Average Items in System = Arrival Rate × Average Time in System. Translated: if your queue is big, work will be slow—no matter how many pep talks you give.
Why this compounds
- Predictable delivery: shorter queues mean steadier lead times.
- Fewer half‑done tasks: less juggling, fewer merge conflicts, fewer “where were we?” meetings.
- Calmer ops: incidents clear faster when you minimize wait states and handoffs.
Metaphor
- Coffee shop line: if the line wraps the block, even great baristas can’t make your latte feel fast. The trick is reducing how many orders wait at once.
How to do it
- Visualize the queue
- A simple board shows “To‑Do, Doing, In Review, Waiting on X, Done.” Count real items “in system” (including “Waiting”).
- Lower WIP to lower wait
- Cap “Doing + In Review” per person or team. Finishing frees the system more than starting.
- Slice thinner
- Prefer changes that ship in days, not weeks. Thin slices keep queues short and feedback fast.
- Kill hidden queues
- Lengthy reviews, long test runs, approvals—treat them as queues. Add SLAs or automate to shrink them.
- Track lead time weekly
- Plot “code commit → production” median. When it rises, find the longest queue and shorten it.
Try this today
- Set a WIP limit of 1–2 per engineer for the next sprint. Measure median lead time before/after. Keep whatever made the line shorter.
Further reading
- Little’s Law explained (succinct). Wikipedia
- “The Principles of Product Development Flow” (queueing in product/dev). Don Reinertsen
- DORA metrics and flow outcomes. Google Cloud: DORA
Quick Recap
- Coupling & Cohesion: crank cohesion up, coupling down—fewer ripples, faster change.
- Data Lineage: give numbers a paper trail—debug faster, build trust.
- Little’s Law: smaller queues mean faster flow—limit WIP, slice thin, clear hidden waits.
Keep compounding: design parts that tell one story, leave breadcrumbs for every number, and keep your lines short. Momentum follows.