Design Principles


Practice Across Design Principles

Use the master deck when you want to retrieve the shared vocabulary across the design-principles section, then use the master quiz to practice choosing principles in realistic design situations.

Design Principles Master Flashcards

A comprehensive mix of the design-principles flashcards: Separation of Concerns, Information Hiding, SOLID, and Design with Reuse.

Difficulty: Basic

What is the Separation of Concerns (SoC) design principle?

Difficulty: Basic

Who coined the term ‘separation of concerns’, and when?

Difficulty: Basic

Define a concern in the phrase ‘Separation of Concerns’.

Difficulty: Basic

Name five practical benefits of applying SoC.

Difficulty: Basic

What is the difference between SoC and Information Hiding?

Difficulty: Basic

How does SoC relate to the SOLID Single Responsibility Principle (SRP)?

Difficulty: Basic

What are the two layers in the lecture’s Monopoly example, and who knows about whom?

Difficulty: Basic

What is a crosscutting concern, and why is it special?

Difficulty: Basic

Name the three concerns separated by HTML, CSS, and JavaScript.

Difficulty: Basic

What is the Massive View Controller anti-pattern, and what principle does it violate?

Difficulty: Basic

Give a five-step method to apply SoC when structuring (or restructuring) a piece of code.

Difficulty: Basic

When is applying SoC a BAD idea?

Difficulty: Basic

What’s the relationship between SoC and the metrics ‘cohesion’ and ‘coupling’?

Difficulty: Basic

In layered architecture, which way do dependencies flow?

Difficulty: Basic

True or false: ‘Separation of Concerns means making everything private.’

Difficulty: Basic

State the Information Hiding principle in one sentence.

Difficulty: Basic

Who introduced the Information Hiding principle, and in what year and venue?

Difficulty: Basic

What two example modularizations did Parnas compare in his 1972 paper, and which won?

Difficulty: Basic

Define a module in the Parnas sense.

Difficulty: Basic

Name the two parts every module has, and which one should be stable.

Difficulty: Basic

Give five categories of design decisions that are commonly worth hiding inside a module.

Difficulty: Basic

What is the difference between a deep module and a shallow module?

Difficulty: Basic

True or false: ‘If I make all my fields and methods private, I have followed the Information Hiding principle.’

Difficulty: Basic

Define coupling and cohesion, and say which way each should go.

Difficulty: Basic

Distinguish syntactic and semantic coupling. Why is the second one more dangerous?

Difficulty: Basic

In the lecture’s payment-system example, what is the secret, and where should it live?

Difficulty: Basic

Why is whether a network protocol is stateful or stateless part of the interface, not the secret?

Difficulty: Basic

What is change impact analysis, and how does it test whether your design follows Information Hiding?

Difficulty: Basic

Name three common anti-patterns of poor Information Hiding.

Difficulty: Basic

When is applying Information Hiding a bad idea?

Difficulty: Basic

How does Information Hiding relate to Separation of Concerns (SoC)?

Difficulty: Basic

Why did the lecture connect Information Hiding to the Software Crisis and modern software scale?

Difficulty: Basic

What does the formula n * (n - 1) / 2 remind you about module design?

Difficulty: Basic

What are the symptoms of a Big Ball of Mud architecture?

Difficulty: Basic

State the Single Choice principle.

Difficulty: Basic

Why can PayPal be both visible and hidden, depending on the boundary?

Difficulty: Advanced

What four sections should a useful design doc include for an Information Hiding decision?

Difficulty: Basic

What question tests whether a module deserves to exist under Information Hiding?

Difficulty: Basic

Name two operating-system design decisions that user programs should not have to know.

Difficulty: Advanced

What problem does a module guide solve in a large information-hiding design?

Difficulty: Advanced

What are Parnas’s two main causes of software aging?

Difficulty: Basic

Why does Parnas say, ‘Designing for change is designing for success’?

Difficulty: Basic

What does it mean to treat an interface as permission to assume?

Difficulty: Advanced

Why was Parnas’s circular-shift ordering in the improved KWIC design still a design error?

Difficulty: Advanced

What is the difference between a primary secret and a secondary secret in a module guide?

Difficulty: Basic

Why can an API named search_bm25 leak information even if its fields are private?

Difficulty: Basic

Why might a more modular design feel harder to understand at first?

Difficulty: Basic

How is a Parnas-style module different from a runtime process?

Difficulty: Basic

State the modern definition of the Single Responsibility Principle (SRP).

Difficulty: Basic

Why is ‘a class should only do one thing’ a MISLEADING restatement of SRP?

Difficulty: Basic

Give the canonical SRP-violating Employee example and its fix.

Difficulty: Basic

How does SRP reduce merge conflicts on a multi-team codebase?

Difficulty: Basic

When is splitting a class into two INCORRECT from an SRP perspective?

Difficulty: Basic

State the Liskov Substitution Principle in one sentence (informal form).

Difficulty: Basic

State Liskov’s three Design-by-Contract rules for a subclass method.

Difficulty: Basic

Why does a self-consistent Square still violate LSP when substituted for Rectangle?

Difficulty: Basic

What is the Refused Bequest smell, and how does it relate to LSP?

Difficulty: Basic

Why did Java’s Stack extends Vector become the textbook legacy LSP mistake?

Difficulty: Basic

How does LSP enable the Open/Closed Principle?

Difficulty: Basic

State the Open/Closed Principle and the #1 misconception about it.

Difficulty: Basic

State the Interface Segregation Principle and give a one-line example.

Difficulty: Basic

State the Dependency Inversion Principle and distinguish it from Dependency Injection.

Difficulty: Basic

What does ‘interface ownership’ mean in DIP, and why does it matter?

Difficulty: Basic

What does design with reuse mean?

Difficulty: Basic

Name the two big benefits of reuse.

Difficulty: Basic

What is the difference between internal and external reuse?

Difficulty: Basic

What does Architectural Mismatch by Garlan, Allen, and Ockerbloom (1995/2009) say about reuse?

Difficulty: Basic

What does Design Principle 1: Keep Versions of Your Dependencies Fixed mean, and how do you do it?

Difficulty: Basic

How does Design Principle 2 (update for security patches) interact with Principle 1 (pin versions)? Aren’t they in tension?

Difficulty: Basic

What is the lesson of the left-pad incident (March 2016)?

Difficulty: Basic

Modules with higher maintenance level and popularity are better reuse candidates — but what beats popularity?

Difficulty: Basic

List the items on each side of the cost-benefit scale for external reuse.

Difficulty: Basic

Why did Ariane 5 self-destruct 37 seconds after launch on June 4, 1996?

Difficulty: Basic

What is Design Principle 5: Identify Violated Assumptions?

Difficulty: Basic

What is the difference between a library and a framework?

Difficulty: Basic

State the Hollywood Principle / Inversion of Control in one sentence.

Difficulty: Basic

What does Petre (2009) tell us about how many design alternatives to generate?

Difficulty: Advanced

What are the four steps of the rational decision process (Tang et al., 2008)?

Difficulty: Advanced

Name the four standard parts of a Google-style Design Doc.

Difficulty: Basic

Why is it valuable to delay some design decisions, and how do you keep track of them?

Difficulty: Basic

True or false: Owning the code makes it safe to reuse without further checks.

Difficulty: Basic

When you face a complex design problem, what is the Solve Simpler Problems First habit?

Difficulty: Basic

Heartbleed and left-pad both illustrate that external reuse is not a one-time investment. Why?

Design Principles Master Quiz

A comprehensive mix of the design-principles quizzes: Separation of Concerns, Information Hiding, SOLID, and Design with Reuse.

Difficulty: Basic

Who coined the term “separation of concerns”, and in what context was it first introduced?

Correct Answer:
Difficulty: Basic

Look at this Python snippet. Which Separation-of-Concerns violation is it guilty of?

def render_user_profile(user_id):
    conn = sqlite3.connect("users.db")
    row = conn.execute("SELECT name, email FROM users WHERE id=?", (user_id,)).fetchone()
    print(f"<h1>{row[0]}</h1><p>{row[1]}</p>")
Correct Answer:
Difficulty: Basic

In the Monopoly example from the lecture, the Application Layer (game logic) exposes three kinds of interaction to the Presentation Layer. Which of the following is NOT one of them?

Correct Answer:
Difficulty: Basic

Why is logging almost always considered a crosscutting concern?

Correct Answer:
Difficulty: Basic

A teammate argues: “We don’t need a Presentation/Application separation. We only have one UI, and we never plan to have another. Let’s just put the rules inside the buttons.” When is this argument most reasonable?

Correct Answer:
Difficulty: Basic

The iOS anti-pattern known as Massive View Controller (MVC where controllers balloon into 2,000-line monsters that handle networking, parsing, caching, validation, navigation, and view layout) is best described as:

Correct Answer:
Difficulty: Basic

Which statement best captures the difference between Separation of Concerns and Information Hiding?

Correct Answer:
Difficulty: Basic

You are designing a new service. Which decomposition shows the BEST Separation of Concerns?

Correct Answer:
Difficulty: Basic

Why might splitting an internal helper function into its own class reduce rather than increase the quality of a system?

Correct Answer:
Difficulty: Basic

Which benefit of SoC most directly explains why a team of five developers can work in parallel on one system?

Correct Answer:
Difficulty: Basic

You spot this code in a React component:

function Dashboard() {
  const [data, setData] = useState([]);
  useEffect(() => {
    fetch("/api/data")
      .then(r => r.json())
      .then(raw => {
        // business rule: only show rows with score > 80
        const filtered = raw.filter(x => x.score > 80);
        setData(filtered);
      });
  }, []);
  return <ul>{data.map(d => <li>{d.name}</li>)}</ul>;
}

What is the most important SoC violation here?

Correct Answer:
Difficulty: Basic

Which is the best definition of a concern in the phrase ‘Separation of Concerns’?

Correct Answer:
Difficulty: Basic

Who introduced the Information Hiding principle, and in what paper?

Correct Answer:
Difficulty: Basic

In Parnas’s KWIC (Key Word In Context) example, what was wrong with the conventional decomposition (one module per processing step)?

Correct Answer:
Difficulty: Basic

Look at this Java code:

public class OrderService {
    private final PayPalClient paypal;
    public PayPalCharge checkout(Order o, PayPalAccount acc) {
        paypal.authenticate(acc);
        return paypal.charge(acc.getAccountToken(), o.getTotal());
    }
}

Every field is private. Is this an example of good Information Hiding?

Correct Answer:
Difficulty: Basic

What does Ousterhout mean by a deep module?

Correct Answer:
Difficulty: Basic

A teammate proposes splitting a 30-line helper function into its own class with a one-method interface, “for Information Hiding.” When is this most likely the wrong move?

Correct Answer:
Difficulty: Basic

Which of the following is most likely to be part of the interface (visible) rather than a hidden secret?

Correct Answer:
Difficulty: Basic

Which statement best captures the relationship between Information Hiding and Separation of Concerns (SoC)?

Correct Answer:
Difficulty: Basic

The CFO announces that PayPal will be replaced with Stripe. In a codebase that follows Information Hiding well, what is the expected scope of the change?

Correct Answer:
Difficulty: Basic

Which is the strongest evidence that a module is shallow?

Correct Answer:
Difficulty: Basic

Two modules in your codebase both depend on the assumption “phone numbers are stored as exactly 10 digits, no separators.” There is no shared constant, no shared validator — just two pieces of code that happen to assume the same thing. What is this?

Correct Answer:
Difficulty: Basic

You inherit a UserRepository whose findByEmail method returns sqlite3.Row. Why is this a problem?

Correct Answer:
Difficulty: Basic

In change impact analysis, what does it mean if a single plausible change (say, “we switch from JSON to Protobuf for our wire format”) would force edits across dozens of unrelated modules?

Correct Answer:
Difficulty: Basic

Which of the following is not a typical mechanism for enforcing Information Hiding?

Correct Answer:
Difficulty: Basic

Why does Information Hiding reduce cognitive load on developers reading code?

Correct Answer:
Difficulty: Basic

A reviewer says: “Don’t add an abstraction for this — we only have one database and we’ll never have another.” When is this argument most reasonable?

Correct Answer:
Difficulty: Basic

Why does unmanaged complexity grow so quickly as a system adds more modules?

Correct Answer:
Difficulty: Basic

In a client/server checkout system, which statement best handles the PayPal decision?

Correct Answer:
Difficulty: Basic

OrderService, RefundService, and WalletService each contain the same switch over paypal, stripe, and apple-pay. Which principle is most directly being violated?

Correct Answer:
Difficulty: Basic

What is the strongest evidence that a design is turning into a Big Ball of Mud?

Correct Answer:
Difficulty: Advanced

Which design-doc content is most useful to a future maintainer who asks, “Why does this PaymentGateway abstraction exist?”

Correct Answer:
Difficulty: Basic

You are reviewing a proposed EmailHelper module. Nobody can name a design decision it owns, and every method is a one-line pass-through to a library call. What is the best Information Hiding critique?

Correct Answer:
Difficulty: Basic

Which operating-system example best illustrates Information Hiding?

Correct Answer:
Difficulty: Advanced

In Parnas, Clements, and Weiss’s A-7E work, what is the main purpose of a module guide?

Correct Answer:
Difficulty: Advanced

According to Parnas’s Software Aging, why can a successful product become harder to maintain over time?

Correct Answer:
Difficulty: Basic

A support tool exposes this public API:

search_bm25(query: str) -> list[tuple[sqlite3.Row, float, int]]

The caller uses the row fields, compares the BM25 score to 0.75, and uses the integer as a posting-list tie breaker. Which redesign best follows Information Hiding?

Correct Answer:
Difficulty: Basic

A team creates DatabaseWrapper.execute_sql(sql) and has service-layer code call it everywhere. What is the best critique?

Correct Answer:
Difficulty: Advanced

In a module-guide card for PaymentGateway, which entry best distinguishes primary and secondary secrets?

Correct Answer:
Difficulty: Advanced

Which statement correctly separates Parnas’s module structure, uses structure, and process structure?

Correct Answer:
Difficulty: Basic

A student says, “The monolithic version is easier to understand because all the code is on one page. The modular version has more names to learn.” What is the best response?

Correct Answer:
Difficulty: Basic

Which of the following best captures Robert C. Martin’s modern formulation of the Single Responsibility Principle (SRP)?

Correct Answer:
Difficulty: Basic

You review this class:

class Invoice {
    BigDecimal calculateTax()       // tax logic, changed by Accounting
    String renderHtml()             // layout, changed by the Web team
    void saveToDatabase()           // persistence, changed by the DBA team
}

What is the BEST refactor, given SRP?

Correct Answer:
Difficulty: Basic

A teammate refactors a 40-line OrderValidator class into three micro-classes: OrderValidator, OrderAuditLogger, and OrderErrorFormatter. In practice, all three change only when the order business rules change — and always together. Evaluating this refactor against SRP:

Correct Answer:
Difficulty: Basic

Which argument for SRP is strongest from a team-productivity perspective?

Correct Answer:
Difficulty: Basic

According to Liskov’s Design-by-Contract formulation, a subclass method must:

Correct Answer:
Difficulty: Basic

Consider this code:

class Bird        { void fly() { /* soar */ } }
class Ostrich extends Bird {
    void fly() { throw new UnsupportedOperationException(); }
}

void release(List<Bird> birds) { for (Bird b : birds) b.fly(); }

Which fix best addresses the LSP violation without introducing a new one?

Correct Answer:
Difficulty: Basic

You are asked to review this subclass contract:

class Queue           { void enqueue(Object x) { /* accepts any non-null */ } }
class StringQueue extends Queue {
    @Override void enqueue(Object x) {
        if (!(x instanceof String)) throw new IllegalArgumentException();
        // ...
    }
}

Which LSP rule does StringQueue violate, and why?

Correct Answer:
Difficulty: Basic

The chapter says a Square class can perfectly enforce its own geometric invariants and still violate LSP when used in place of a Rectangle. Which statement best explains why?

Correct Answer:
Difficulty: Basic

A ShippingCostCalculator uses a long switch on carrier (UPS, FedEx, USPS). Management wants to add DHL next week. Which refactor best satisfies the Open/Closed Principle?

Correct Answer:
Difficulty: Basic

A Printer interface exposes print(), scan(), fax(), and staple(). A simple home printer class must implement all four but throws UnsupportedOperationException on scan, fax, and staple. Which SOLID principle is most directly violated, and what is the correct fix?

Correct Answer:
Difficulty: Basic

Which scenario shows the correct application of the Dependency Inversion Principle?

Correct Answer:
Difficulty: Basic

The chapter argues SOLID principles reinforce each other. Which pairing below best captures a genuine dependency between two principles?

Correct Answer:
Difficulty: Basic

Which of the following is not typically a benefit of software reuse?

Correct Answer:
Difficulty: Basic

In the lecture’s terminology, which scenario is external reuse rather than internal reuse?

Correct Answer:
Difficulty: Basic

You install a Python package today with pip install foo. Six months from now, a colleague clones the repo and runs the same command. Their build fails because a transitive dependency just released a major version with API-breaking changes. Which design principle does this most directly violate?

Correct Answer:
Difficulty: Basic

The Heartbleed bug (CVE-2014-0160) sat in OpenSSL for two years before public disclosure, and was still on tens of thousands of devices five years after a patch was available. Which two principles does this story most directly support?

Correct Answer:
Difficulty: Basic

You’re considering adding a 12-line npm dependency that capitalizes the first letter of each word in a string. The package has 7 GitHub stars and one maintainer with no commits in the last year. Which course of action best follows the chapter’s principles?

Correct Answer:
Difficulty: Basic

The Ariane 5 self-destruction 37 seconds into its maiden flight was caused by reusing the Inertial Reference System software from Ariane 4 without re-checking that a 16-bit integer was large enough for Ariane 5’s higher horizontal velocity. The ESA inquiry’s Recommendation R5 generalizes this into a single design principle. Which one?

Correct Answer:
Difficulty: Basic

Consider these two snippets:

// Snippet A — Axios
const response = await axios.get('/user?ID=12345');
// Snippet B — Express
app.get('/', (req, res) => { res.send('Hello World!'); });

Which statement about Snippet A vs. Snippet B is correct?

Correct Answer:
Difficulty: Basic

A team is choosing whether to rewrite an old internal BatchScheduler for use in a new low-latency streaming service. Which course of action best embodies the design principles in this chapter?

Correct Answer:
Difficulty: Basic

Which of the following are documented costs of external reuse that a team should weigh before adding a dependency? Select all that apply.

Correct Answers:
Difficulty: Basic

In Petre’s expert-design study, three teams designed the same system: Team A produced 1 detailed design, Team B produced 3 options, Team C produced 5 options. Expert reviewers ranked Team C’s chosen design as the best. What is the correct takeaway?

Correct Answer:
Difficulty: Basic

Which of the following is not typically a section in a Design Doc as practiced at Google?

Correct Answer:
Difficulty: Basic

Your team is choosing between two CSV-parsing libraries:

  • Library X has 50,000 GitHub stars, is downloaded 10M times/week, and is actively maintained — but does not stream rows from disk, so it loads the full file into memory.
  • Library Y has 800 GitHub stars and one active maintainer, and does support streaming from disk.

Your service routinely parses 2 GB CSV files on memory-constrained containers.

Which principle most directly resolves the choice?

Correct Answer:

Separation of Concerns

Separation of Concerns teaches how to split a system so each part addresses a distinct concern, such as UI, business rules, storage, or communication.

Information Hiding

Information Hiding teaches how to hide difficult or likely-to-change design decisions behind stable interfaces, so change stays local instead of becoming a Big Ball of Mud.

SOLID

SOLID gives five object-oriented principles for localizing change: single responsibility, open/closed design, substitutable subtypes, focused interfaces, and dependency inversion.

Design with Reuse

Design with Reuse explains when reuse helps, when it creates hidden coupling, and how to compose internal and external components without letting their assumptions leak everywhere.