Mental Models

How Programmers Think

The cognitive patterns, habits, and frameworks that separate great engineers from the rest.

The Four Core Pillars
๐Ÿงฉ

Decomposition

Break every complex problem into the smallest possible independent parts before writing a single line.

๐Ÿ”ฎ

Abstraction

Hide complexity behind clean interfaces. Work at the right level โ€” neither too high nor too low.

๐Ÿ”

Pattern Recognition

Every new problem echoes a solved one. The best engineers build a vast pattern library in their heads.

๐Ÿงช

Systematic Testing

Think in edge cases first, not last. The happy path is the easy part.

Problem-Solving Pipeline
01
๐Ÿค”

Understand

Restate the problem in your own words. What are the exact inputs and expected outputs?

02
๐Ÿ—บ๏ธ

Plan

Sketch the algorithm. No code yet. What data structures fit? What's the time complexity?

03
โšก

Implement

Write the simplest version that could possibly work. Solve it before optimising it.

04
๐Ÿ”

Review

Read the code as if you've never seen it. Would a stranger understand it in 30 seconds?

05
๐Ÿš€

Refine

Measure before optimising. Profile first, guess never.

๐Ÿ›

The Debugging Mindset

  • โœ“
    Assume nothing โ€” the bug is never where you think it is.
  • โœ“
    Reproduce it first โ€” you can't fix what you can't see.
  • โœ“
    Change one thing at a time โ€” otherwise you learn nothing.
  • โœ“
    Read the error message โ€” it usually tells you exactly what's wrong.
  • โœ“
    Binary search the code โ€” narrow the blast radius systematically.
  • โœ“
    Rubber duck it โ€” explaining the problem aloud finds it faster than staring.
๐Ÿ’ฌ

Code is Communication

You write code once. It gets read dozens of times. Optimise for the reader.

  • โœ“
    Names are documentation โ€” bad names cause more bugs than bad logic.
  • โœ“
    Functions do one thing โ€” if you need "and" to describe it, split it.
  • โœ“
    Comments explain why โ€” the code already says what.
  • โœ“
    Consistency beats cleverness โ€” boring, predictable code is a gift.
  • โœ“
    Delete code bravely โ€” less code, fewer bugs, faster reads.
  • โœ“
    The simplest solution wins โ€” complexity is a cost, not a trophy.
Thinking in Code
pseudocode function solve(problem): // 1. Do I fully understand the constraints? if unclear(problem): ask("What does success look like?") // 2. Have I seen this shape before? pattern = recognise(problem) // sliding window? graph traversal? DP? // 3. What's the naive solution first? naive = brute_force(problem) // complexity: O(nยฒ) โ€” acceptable? if not, optimise now // 4. Test at the boundaries, not just the middle for case in [empty, one_element, max_size, duplicates, negatives]: assert(solve(case) == expected[case]) return refactor(naive) // only after it's correct
Growth vs Fixed Engineering Mindset
Fixed Mindset Growth Mindset
I don't know โ€” I'm stuck โ†’ I don't know yet โ€” I'll figure it out
My code is who I am โ†’ My code is what I made today
The reviewer is wrong โ†’ The reviewer saw something I missed
That's not my bug โ†’ That's an opportunity to learn the system
I already know this pattern โ†’ Is there a better tool for this job?
It works, ship it โ†’ It works โ€” now make it readable
By the Numbers
10ร—
more time reading code than writing it
70%
of bugs introduced during rushed implementations
5ร—
faster to fix a bug found in review vs. production
80%
of complexity lives in 20% of the codebase
๐Ÿ—๏ธ

Hard Skills to Sharpen

Data Structures Algorithms System Design SQL Networking Concurrency Memory Models API Design Performance Profiling
๐Ÿง 

Soft Skills That Compound

Deep Focus Written Clarity Asking Questions Teaching Others Disagreeing Calmly Time Estimation Knowing When to Stop
The Programmer's North Star
๐ŸŽฏ

Make it Work

Correctness is non-negotiable. A fast wrong answer is still wrong. Start here, always.

๐Ÿ“–

Make it Clear

The next person to read this code may be you at 2am. Show them kindness.

โšก

Make it Fast

Only after it works and reads well. Premature optimisation is the root of all evil.