Design Principles Junior
What is a design principle, and how do principles differ from design patterns and hard rules?
Select the correct answer
A principle is a general guideline for decisions; patterns are reusable solutions and rules are strict requirements.
A principle is a testing convention; patterns are naming standards and rules are performance limits set by tools.
A principle is a concrete code template; patterns are abstract ideals and rules are language-specific syntax limits.
A principle is a strict requirement; patterns are optional styles and rules are loose suggestions for beginners.
How does 'divide and conquer' / decomposition serve as a foundational design principle for managing complexity?
Select the correct answer
It breaks a large problem into smaller independent parts that can be understood and solved separately.
It duplicates a problem across modules so each team can solve the same task and compare final results.
It merges many small problems into one large unit so a single algorithm can process everything at once.
It defers a hard problem until later so simpler features ship first and complexity is handled afterwards.
What does designing for 'readability' as a first-class principle mean, and why is code read far more often than it is written?
Select the correct answer
It optimizes code for human comprehension, since code is read far more often than it is written.
It optimizes code for reuse, since shared components are read far more often than one-off scripts are.
It optimizes code for compiler speed, since machines parse code far more often than humans ever review it.
It optimizes code for line count, since shorter files are read far more quickly than longer verbose ones.
What is the Single Responsibility Principle and how do you determine if a class has too many responsibilities? What is the 'one reason to change' rule?
Select the correct answer
A class should perform one action per method, ensuring every method changes for exactly one clear reason.
A class should have only one reason to change, meaning it answers to a single actor or responsibility.
A class should contain only one public method so that any change is always isolated to a single function.
A class should depend on only one other class, limiting the ways external changes can affect its behavior.
What does it mean for a class to have 'one reason to change'? Does this mean a class should only have one method?
Select the correct answer
It should never be modified after release, forcing all changes into brand-new subclasses.
It should change only when the database schema changes, ignoring other business rule updates.
It should answer to one actor or responsibility, which may still require several methods.
It should contain exactly one public method and delegate everything else to helper classes.
Why do we use SOLID principles? What specific problems in a codebase are they designed to solve?
Select the correct answer
To enforce a single coding style so every developer writes their functions the same way.
To reduce coupling and make code easier to maintain, change, and extend safely.
To ensure full test coverage by requiring one unit test per class and per public method.
To guarantee faster runtime performance by removing abstraction layers from hot paths.
What is the difference between Coupling and Cohesion? Why is 'High Cohesion, Low Coupling' considered the gold standard of software design?
Select the correct answer
Coupling measures test coverage; cohesion measures how many comments the code contains.
Coupling is the number of classes; cohesion is the number of methods inside each class.
Coupling is inter-module dependence; cohesion is how focused one module's tasks are.
Coupling is compile-time linkage; cohesion is the runtime memory shared across modules.
What is the difference between coupling and cohesion? Which one is more dangerous to get wrong?
Select the correct answer
Coupling is dependency between modules, cohesion is focus within one; high coupling is more dangerous.
Coupling measures reuse and cohesion measures test scope; both are equally dangerous to get wrong here.
Coupling is focus within a module, cohesion is dependency between them; low cohesion is more dangerous.
Coupling and cohesion both measure module size, and getting cohesion wrong is far more dangerous overall.
Explain the conceptual difference between an 'is-a' relationship and a 'has-a' relationship at the design level.
Select the correct answer
'Is-a' models two identical classes merged; 'has-a' models a class copying fields from another at construction.
'Is-a' models an object holding a reference; 'has-a' models a class extending another to inherit its behavior.
'Is-a' models a subtype that is a kind of its parent; 'has-a' models one object owning another as a part.
'Is-a' models interface implementation only; 'has-a' models runtime creation of temporary objects in a method.
What is a 'God Object' (or Blob), and why is it considered an anti-pattern in object-oriented design?
Select the correct answer
An interface implemented by every class; bad because it forces unrelated types to share unneeded method signatures.
A single class concentrating most logic and data; bad because it has low cohesion, high coupling, and resists testing.
A class exposing only static methods; bad because it prevents inheritance and makes mocking it in tests impossible.
A tiny class delegating to many helpers; bad because it adds needless indirection and hides behavior from readers.
What is the 'Boy Scout Rule', and how does it help a codebase preserve adherence to design principles as it evolves?
Select the correct answer
Always leave code cleaner than you found it; small continuous improvements prevent gradual design decay.
Rewrite each module fully before adding features; large upfront cleanups keep the design perpetually pristine.
Never modify code you did not originally write; limiting edits keeps the design stable and consistent.
Only refactor during dedicated sprints; batching cleanup avoids risky changes mixed into feature work.