Software Design Principles Flashcards
7 cards from real CPSA practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Software Design Principles flashcards as text
Which statement BEST describes the Open/Closed Principle?
Answer: Software entities should be open for extension but closed for modification
The Open/Closed Principle states that software entities should be open for extension (new behavior can be added) but closed for modification (existing code is not changed).
A designer uses inheritance but the subclass cannot be used wherever the parent class is expected without breaking behavior. Which principle is violated?
Answer: Liskov Substitution Principle
The Liskov Substitution Principle requires that subtype objects must be substitutable for their supertype objects without altering program correctness.
What is the PRIMARY benefit of applying the DRY (Don't Repeat Yourself) principle?
Answer: Reduced risk of inconsistency when changing logic in one place
DRY reduces duplication so that when logic must change, it is updated in exactly one place, eliminating the risk of inconsistent copies.
Which design heuristic does the statement 'You should not design for needs that do not yet exist' represent?
Answer: YAGNI (You Aren't Gonna Need It)
YAGNI advises against implementing functionality until it is actually needed, avoiding unnecessary complexity and speculative design.
In layered architecture, what design principle is enforced when higher layers only interact with the layer directly below them?
Answer: Layer isolation / strict layering
Strict layering enforces that each layer only communicates with the adjacent lower layer, maintaining clear boundaries and reducing coupling across layers.
Which principle is MOST directly supported by using dependency injection?
Answer: Dependency Inversion Principle
Dependency injection is a common technique for implementing the Dependency Inversion Principle, allowing high-level modules to depend on abstractions rather than concrete low-level classes.
A class has methods for user authentication, report generation, and database connection management. Which principle does this MOST violate?
Answer: Single Responsibility Principle
Bundling authentication, reporting, and database management into one class gives it multiple reasons to change, violating the Single Responsibility Principle.