1. Home
  2. Explore
  3. Computer Science
  4. John Ousterhout Google Talk

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

John Ousterhout Google Talk

A Philosophy of Software Design

Problem Decomposition: The Core of Computer Science

The single most important concept spanning all of computer science is problem decomposition — how to take a complicated problem or system and break it into pieces that can be built relatively independently. This idea threads through AI, systems, theory, and every other subfield. Despite its fundamental importance, it is almost never explicitly taught as a core skill in academic courses. Abstraction, composition, and complexity are related, but decomposition is the enabling mechanism behind them all.

The ability to decompose problems well is what separates highly productive programmers from average ones — the so-called 10x programmer. Yet these skills are generally not taught formally; great programmers seem to acquire them through personal experience and trial and error. This observation raises three key questions:

  • Is it even possible to teach software design, or is it an innate talent?

  • Who is qualified to teach it, given that most faculty lack extensive industrial coding experience?

  • How should such a course be structured to actually develop design skills?

Research on expertise (Geoff Colvin's Talent Is Overrated) shows that in fields where some people appear extraordinarily talented, the only consistent differentiator is the amount and quality of practice — not innate gifts. This suggests that design can indeed be taught, provided the right pedagogical approach is used.


Teaching Software Design: The Stanford CS 190 Approach

The Iterative Method

Professor Ousterhout created a new course at Stanford, CS 190: Software Design Studio, modeled not on typical computer science courses but on how students learn English writing in high school — through iterative cycles of creation, critique, and revision. The key insight is that students learn design best by making mistakes, receiving detailed feedback, and then applying that feedback to improve.

The quarter system (10 weeks) allows three iterations of this cycle:

  1. First phase (3 weeks): Students work in pairs to build the largest system they can — typically 2,000–3,000 lines of code. No design guidance is given; students must figure everything out themselves, ensuring they make plenty of mistakes.

  2. Code review phase: Students read each other's code and write reviews. The instructor reads every line of code from all teams (20,000–30,000 lines per cycle), making 50–100 comments per team, then meets individually with each team for an hour. In-class code reviews involve students presenting their work and receiving peer critique.

  3. Second phase: Students revise their code based on the reviews and add a small amount of new functionality.

  4. Third phase: Students receive a new project and start from scratch, repeating the process with a final round of code reviews.

This approach forces students to confront their design decisions directly. The abstract principles discussed in lectures rarely sink in during the first phase; they become meaningful only during code reviews, when students can see exactly how they violated a principle and understand the consequences in concrete terms.

Why Not Use Teaching Assistants?

A major bottleneck is that the instructor reads every line of student code personally. This is intentional: the feedback must be at a high enough level to address genuine design issues, not just style concerns. Teaching assistants without deep design experience might give inconsistent or counterproductive advice — for example, telling students to break methods shorter than 20 lines, which contradicts the course's core principles. Future offerings might use previous students as TAs or experienced software engineers who align with the course philosophy.


Design Principles: Deep Classes

The Idea of Depth

The most fundamental design principle is that classes should be deep. This reframes David Parnas's classic work on information hiding (1972) in a more intuitive, quantitative way.

Think of a class as a rectangle:

  • Area = the functionality the class provides (its benefit to the rest of the system)

  • Top edge = the interface — everything a user must know to use the class (signatures, side effects, dependencies, assumptions). This is the complexity cost imposed on the rest of the system.

Ideally, we want maximum benefit (large area) at minimum cost (small interface). A deep class has a very simple interface that hides a large amount of complex implementation. This is the essence of good abstraction: providing a simple way to think about something that is actually quite complicated underneath.

A shallow class has either little functionality, a complicated interface, or both. Such classes give little leverage against complexity. In the worst case, the overhead of the interface exceeds the value of what's hidden, making the class a net negative.

Common Violation: Classitis

The single biggest design mistake people make is creating too many small, shallow classes. This pathology — classitis — arises from the widespread teaching that "methods should be small" (often with arbitrary line limits like 20 or even 10 lines). When over-applied, this leads to classes that add only a tiny amount of new functionality each, with interfaces that reveal almost everything about their implementation.

The Java Class Library exemplifies classitis. Opening a file to read serialized objects requires creating three separate objects (file stream, buffering stream, object stream), each with its own exceptions to catch. The common case — the one that should be dead simple — is enormously complex. Buffering should be the default, not an extra step the programmer must remember to request.

Proper Response to Length

Length is not the fundamental issue. A method hundreds of lines long can be acceptable if it has a deep interface — meaning users don't need to understand its internals to use it correctly. The priority should always be achieving a deep abstraction first. Only after that should one consider breaking a large method into smaller pieces, and only if those pieces themselves have deep interfaces.

Beautiful Example: Unix File I/O

The Unix file I/O interface (open, close, read, write, lseek) is one of the most beautiful interfaces ever created. Five functions with an astonishingly simple interface hide hundreds of thousands of lines of code managing disk space, file caching, device drivers, and lower-level interfaces. Before Unix, file systems required different kernel calls for random-access versus sequential-access files — a stark contrast in complexity. The Unix design was revolutionary in its simplicity.


Design Principles: Define Errors Out of Existence

The Problem with Exceptions

Exceptions are a huge source of complexity in systems. In RAMCloud, a low-latency storage system, 90% of development time went into crash recovery rather than the core functionality. The common wisdom of "program defensively" often leads people to throw as many exceptions as possible, assuming that's the responsible thing to do. But this creates an explosion of exceptions that must be caught and handled, which in turn introduces more bugs, secondary exceptions, and overall system fragility.

The goal should be to minimize the number of places where exceptions must be handled. The best case — and one that can be achieved surprisingly often — is to redefine semantics so that the exceptional condition simply ceases to exist.

Example 1: Tcl's unset Command

The original unset command threw an exception if the variable to be deleted did not exist. The reasoning was: "Why would anyone delete a nonexistent variable?" In practice, users frequently wanted to clean up variables during error recovery without knowing which ones had been created. Virtually every invocation of unset was wrapped in a catch block to suppress the exception. The proper design would have defined unset as making a variable not exist — if it already doesn't exist, nothing needs to happen. This eliminates the exception entirely.

Example 2: Unix File Deletion During Open

Windows (early versions) prevented deleting a file that was open, leading to a frustrating hunt for the process holding the file — sometimes a system daemon that couldn't be killed without rebooting, after which the file was still in use. Unix solved this elegantly: deleting a file removes it from the directory namespace immediately, but the file's contents remain accessible to any process that already has it open. When the last open handle is closed, the storage is reclaimed. No errors are generated on either side — the system simply does the right thing.

Example 3: Substring Methods

Java's substring methods throw exceptions if indices are out of range or in reverse order. This forces programmers to write extra code to clip indices before calling the method, defeating the purpose. A better design would define substring to return the overlap between the requested range and the available string: out-of-bound indices are silently clipped to the valid range; reversed indices return an empty string. This eliminates many runtime exceptions and simplifies client code, though it does not eliminate the need for testing.

When Exceptions Are Necessary

Exceptions are still needed when an operation fundamentally cannot fulfill its contract — for example, a read operation encountering an I/O error. The art of software design lies in distinguishing what truly matters from what can be made irrelevant. The goal is to make as little as possible matter, while properly handling what does.

Exceptions vs. Return Values

Exceptions provide the most value when they propagate a long way up the call stack, making it unnecessary for many intermediate layers to deal with an error. When caught locally, exceptions offer little advantage over return values. However, checking a return value is syntactically simpler than writing an exception handler. For errors that should propagate far, exceptions are the right choice; for local, expected conditions, return values may be simpler.

Crashing as a Strategy

In some situations, crashing is the most sensible approach. Running out of memory, for example, is so rare and the complexity of handling it properly so high that most applications should simply print a message and crash. Attempting graceful recovery often introduces more bugs than it prevents, resulting in crashes anyway.


Mindset: Tactical vs. Strategic Programming

The Tactical Trap

Most programmers adopt a tactical mindset: their primary goal is to get something working — the next feature, the next bug fix. This seems natural, but it leads to a pernicious pattern: "I'll make it mostly clean, but a few shortcuts or kludges are fine as long as I don't do too many." The problem is that these shortcuts accumulate rapidly, because everyone on the team is doing the same thing. After a few deadlines, the system is full of compromises, and cleaning them up would take weeks — time no one has. The result is spaghetti code that becomes harder and harder to maintain.

Complexity is not caused by a single big mistake; it is the accumulation of hundreds or thousands of small compromises made by many people over time. This gradual degradation goes unnoticed until it's too late, and then it's almost impossible to fix because there is no single root cause.

Tactical tornadoes are extreme cases — programmers who churn out enormous amounts of shoddy code that mostly works, leaving destruction in their wake. Many organizations mistakenly reward these individuals as heroes ("the 10x programmer"), when in fact they are creating massive future debt.

The Strategic Alternative

A strategic approach recognizes that working code is not enough — it's table stakes. The real goal is a great design, because that is what enables fast future development. Good design is an investment: spending a little extra time today to keep complexity in check pays back many times over in the months and years ahead.

Key elements of strategic programming:

  • Zero tolerance for small messes. Complexity is insidious; every little kludge adds up. Don't let lint creep in.

  • Accept that you'll go slower at first, but trust that the investment will pay off.

  • Always look for something to improve when making changes. Every modification is an opportunity to leave the code better than you found it. This is essential because changes almost always introduce some complexity; to break even, you must also reduce complexity elsewhere.

  • Aim for what you would have built if you'd known everything from the start. This is the ideal — though sometimes impractical within the scope of a single change.

The Investment Math

The tactical approach yields fast initial development but rapidly slows as complexity grows. The strategic approach starts slower but maintains a higher velocity over the long term. The crossover point — where strategic catches up to tactical in cumulative productivity — is estimated to be somewhere in the 6-to-12-month range, though no quantitative data exists to confirm this.

The challenge is that the cost of investment is visible today, but the benefit is delayed and hard to quantify. Managers and developers naturally optimize for the short term. To counteract this, organizations should explicitly commit to investing something like 10–20% of resources into design improvement, not just feature development.

The Example of Facebook

Facebook's original motto — "move fast and break things" — exemplified extreme tactical programming. It empowered new hires (they could push to production in their first week) but resulted in a notoriously messy codebase. Interns who experienced Facebook's code returned with a newfound appreciation for unit tests and documentation. Eventually, Facebook changed its motto to "move fast with stable infrastructure," but whether the mess can be cleaned up is unclear.

Google and VMware as Counterexamples

Google and VMware in their early years (2000–2010) were known for a strong design culture that attracted top programming talent. This gave them a significant recruiting advantage. Since the best programmers are 10x more productive, the strongest argument for a good design culture may be its ability to attract and retain the best people. Companies with crappy code can succeed (Facebook), but companies with great design cultures have a competitive edge in hiring.


Practical Advice: Making Strategic Programming Work

How Much to Invest

The right amount to invest is as much as you can afford at your current stage. For most organizations, 10–20% is feasible — going 10% slower today is a small price for future gains. The investment is not a sunk cost; it will be returned, likely within months.

Small Steps, Not Heroics

It is impossible to design a complete system perfectly upfront. Software development must be iterative. When building new modules:

  • Take time to design the interface carefully.

  • Strive for deep classes.

  • Write documentation as you go.

  • Write unit tests (though they are not the focus of the course, they are crucially important in practice).

When Making Changes

  • Don't take the first easy way out. The temptation is to make the smallest possible change — a hack that directly accesses a global variable instead of finding a clean interface. Resist this.

  • Ask: is this the best I can possibly do? If not, do better. This is a personal discipline, not something a manager can enforce.

  • Treat design improvement as part of every task. Even if you can't achieve the ideal, do the most you can within the available time.

Layering and Performance

Layers are essential for managing complexity, but too many skinny layers are a common mistake. The solution is a smaller number of meatier layers with deep interfaces. For performance-critical systems, think about key performance metrics early and define layers in a way that allows high throughput without sacrificing abstraction. Performance and layering are not fundamentally opposed; thoughtful design can achieve both.


Red Flags: Recognizing Poor Design

Red flags are specific, observable patterns that indicate problems. They are especially useful for beginners: even if you don't know how to design well, recognizing a red flag tells you something is wrong, and you can try different approaches until the flag goes away.

Examples from the talk:

  • Classitis: Too many small classes where each adds minimal functionality.

  • Shallow methods: Methods that take more keystrokes to invoke than their body would require — a clear sign of no information hiding.

  • Exception-happy interfaces: Interfaces that throw exceptions for conditions that could be defined away (e.g., substring out-of-bounds).

  • Code that is modified by the smallest possible change: Indicates fear of the codebase and a tactical mindset.


The Course in Practice: Observations and Results

Student Transformation

The class has a distinctive energy. In the first code review round, students are tentative and reluctant to criticize peers. After the instructor's intensive one-hour reviews, they realize "I can do that too." By the second round, discussions become lively as students argue about which approach is more complex. By the end of the quarter, students think about programming in a fundamentally different way — they have developed design awareness.

Instructor Learning

Teaching the course has also improved the instructor's own design skills. Reading 20,000 lines of code three times per quarter from many students doing the same task reveals common mistakes and alternative approaches. One important insight that emerged: making classes slightly general-purpose — even when you only need them in one place — often yields much simpler, deeper interfaces. This counterintuitive observation came from comparing student projects.

Scalability Challenge

The current approach is woefully non-scalable: the instructor must read every line of code personally to give high-quality feedback. Scaling to more students will require either more experienced readers (training past students as TAs, or enlisting software engineers who buy into the philosophy) or automated tools that can flag certain red flags. The scarcity of people with both deep design experience and the willingness to mentor is the primary bottleneck.


The Book: A Philosophy of Software Design

The book (170 pages) is a distillation of the course's ideas. It is intentionally philosophical rather than prescriptive — there is no 10-step recipe for good design. Instead, it aims to:

  • Provide a shared vocabulary for discussing design (deep classes, tactical tornadoes, etc.)

  • Offer red flags that help people recognize when they're going wrong

  • Serve as a lightning rod to provoke discussion and debate in the software community

The hope is that the book will evolve through feedback, much like software itself — version 3.0 will be better than 1.0. A mailing list exists for discussion, though it has seen little traffic so far.


Final Thoughts

Software design remains a black art after more than 80 years of programming. There is almost no agreement on how to do it or even what constitutes good design. This talk and the associated course and book are a first attempt to change that — to start a conversation, define terms, and raise design awareness across the community.

The long-term goal, five or ten years from now, is to have a relatively robust set of design principles that most developers agree are beneficial. Achieving this will require input, criticism, and real-world experience from many practitioners. The journey from version 1.0 to version 3.0 depends on the community's willingness to engage.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent