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.
What is the Separation of Concerns (SoC) design principle?
Who coined the term ‘separation of concerns’, and when?
Define a concern in the phrase ‘Separation of Concerns’.
Name five practical benefits of applying SoC.
What is the difference between SoC and Information Hiding?
How does SoC relate to the SOLID Single Responsibility Principle (SRP)?
What are the two layers in the lecture’s Monopoly example, and who knows about whom?
What is a crosscutting concern, and why is it special?
Name the three concerns separated by HTML, CSS, and JavaScript.
What is the Massive View Controller anti-pattern, and what principle does it violate?
Give a five-step method to apply SoC when structuring (or restructuring) a piece of code.
When is applying SoC a BAD idea?
What’s the relationship between SoC and the metrics ‘cohesion’ and ‘coupling’?
In layered architecture, which way do dependencies flow?
True or false: ‘Separation of Concerns means making everything private.’
State the Information Hiding principle in one sentence.
Who introduced the Information Hiding principle, and in what year and venue?
What two example modularizations did Parnas compare in his 1972 paper, and which won?
Define a module in the Parnas sense.
Name the two parts every module has, and which one should be stable.
Give five categories of design decisions that are commonly worth hiding inside a module.
What is the difference between a deep module and a shallow module?
True or false: ‘If I make all my fields and methods private, I have followed the Information Hiding principle.’
Define coupling and cohesion, and say which way each should go.
Distinguish syntactic and semantic coupling. Why is the second one more dangerous?
In the lecture’s payment-system example, what is the secret, and where should it live?
Why is whether a network protocol is stateful or stateless part of the interface, not the secret?
What is change impact analysis, and how does it test whether your design follows Information Hiding?
Name three common anti-patterns of poor Information Hiding.
When is applying Information Hiding a bad idea?
How does Information Hiding relate to Separation of Concerns (SoC)?
Why did the lecture connect Information Hiding to the Software Crisis and modern software scale?
What does the formula n * (n - 1) / 2 remind you about module design?
What are the symptoms of a Big Ball of Mud architecture?
State the Single Choice principle.
Why can PayPal be both visible and hidden, depending on the boundary?
What four sections should a useful design doc include for an Information Hiding decision?
What question tests whether a module deserves to exist under Information Hiding?
Name two operating-system design decisions that user programs should not have to know.
What problem does a module guide solve in a large information-hiding design?
What are Parnas’s two main causes of software aging?
Why does Parnas say, ‘Designing for change is designing for success’?
What does it mean to treat an interface as permission to assume?
Why was Parnas’s circular-shift ordering in the improved KWIC design still a design error?
What is the difference between a primary secret and a secondary secret in a module guide?
Why can an API named search_bm25 leak information even if its fields are private?
Why might a more modular design feel harder to understand at first?
How is a Parnas-style module different from a runtime process?
State the modern definition of the Single Responsibility Principle (SRP).
Why is ‘a class should only do one thing’ a MISLEADING restatement of SRP?
Give the canonical SRP-violating Employee example and its fix.
How does SRP reduce merge conflicts on a multi-team codebase?
When is splitting a class into two INCORRECT from an SRP perspective?
State the Liskov Substitution Principle in one sentence (informal form).
State Liskov’s three Design-by-Contract rules for a subclass method.
Why does a self-consistent Square still violate LSP when substituted for Rectangle?
What is the Refused Bequest smell, and how does it relate to LSP?
Why did Java’s Stack extends Vector become the textbook legacy LSP mistake?
How does LSP enable the Open/Closed Principle?
State the Open/Closed Principle and the #1 misconception about it.
State the Interface Segregation Principle and give a one-line example.
State the Dependency Inversion Principle and distinguish it from Dependency Injection.
What does ‘interface ownership’ mean in DIP, and why does it matter?
What does design with reuse mean?
Name the two big benefits of reuse.
What is the difference between internal and external reuse?
What does Architectural Mismatch by Garlan, Allen, and Ockerbloom (1995/2009) say about reuse?
What does Design Principle 1: Keep Versions of Your Dependencies Fixed mean, and how do you do it?
How does Design Principle 2 (update for security patches) interact with Principle 1 (pin versions)? Aren’t they in tension?
What is the lesson of the left-pad incident (March 2016)?
Modules with higher maintenance level and popularity are better reuse candidates — but what beats popularity?
List the items on each side of the cost-benefit scale for external reuse.
Why did Ariane 5 self-destruct 37 seconds after launch on June 4, 1996?
What is Design Principle 5: Identify Violated Assumptions?
What is the difference between a library and a framework?
State the Hollywood Principle / Inversion of Control in one sentence.
What does Petre (2009) tell us about how many design alternatives to generate?
What are the four steps of the rational decision process (Tang et al., 2008)?
Name the four standard parts of a Google-style Design Doc.
Why is it valuable to delay some design decisions, and how do you keep track of them?
True or false: Owning the code makes it safe to reuse without further checks.
When you face a complex design problem, what is the Solve Simpler Problems First habit?
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.
Who coined the term “separation of concerns”, and in what context was it first introduced?
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>")
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?
Why is logging almost always considered a crosscutting concern?
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?
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:
Which statement best captures the difference between Separation of Concerns and Information Hiding?
You are designing a new service. Which decomposition shows the BEST Separation of Concerns?
Why might splitting an internal helper function into its own class reduce rather than increase the quality of a system?
Which benefit of SoC most directly explains why a team of five developers can work in parallel on one system?
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?
Which is the best definition of a concern in the phrase ‘Separation of Concerns’?
Who introduced the Information Hiding principle, and in what paper?
In Parnas’s KWIC (Key Word In Context) example, what was wrong with the conventional decomposition (one module per processing step)?
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?
What does Ousterhout mean by a deep module?
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?
Which of the following is most likely to be part of the interface (visible) rather than a hidden secret?
Which statement best captures the relationship between Information Hiding and Separation of Concerns (SoC)?
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?
Which is the strongest evidence that a module is shallow?
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?
You inherit a UserRepository whose findByEmail method returns sqlite3.Row. Why is this a problem?
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?
Which of the following is not a typical mechanism for enforcing Information Hiding?
Why does Information Hiding reduce cognitive load on developers reading code?
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?
Why does unmanaged complexity grow so quickly as a system adds more modules?
In a client/server checkout system, which statement best handles the PayPal decision?
OrderService, RefundService, and WalletService each contain the same switch over paypal, stripe, and apple-pay. Which principle is most directly being violated?
What is the strongest evidence that a design is turning into a Big Ball of Mud?
Which design-doc content is most useful to a future maintainer who asks, “Why does this PaymentGateway abstraction exist?”
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?
Which operating-system example best illustrates Information Hiding?
In Parnas, Clements, and Weiss’s A-7E work, what is the main purpose of a module guide?
According to Parnas’s Software Aging, why can a successful product become harder to maintain over time?
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?
A team creates DatabaseWrapper.execute_sql(sql) and has service-layer code call it everywhere. What is the best critique?
In a module-guide card for PaymentGateway, which entry best distinguishes primary and secondary secrets?
Which statement correctly separates Parnas’s module structure, uses structure, and process structure?
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?
Which of the following best captures Robert C. Martin’s modern formulation of the Single Responsibility Principle (SRP)?
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?
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:
Which argument for SRP is strongest from a team-productivity perspective?
According to Liskov’s Design-by-Contract formulation, a subclass method must:
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?
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?
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?
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?
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?
Which scenario shows the correct application of the Dependency Inversion Principle?
The chapter argues SOLID principles reinforce each other. Which pairing below best captures a genuine dependency between two principles?
Which of the following is not typically a benefit of software reuse?
In the lecture’s terminology, which scenario is external reuse rather than internal reuse?
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?
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?
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?
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?
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?
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?
Which of the following are documented costs of external reuse that a team should weigh before adding a dependency? Select all that apply.
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?
Which of the following is not typically a section in a Design Doc as practiced at Google?
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?
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.