1/26
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What does SOLID stand for?
Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
Which SOLID principles are covered in detail in this deck?
Single Responsibility Principle, Open/Closed Principle, and Liskov Substitution Principle.
What is the Single Responsibility Principle?
Every object/class should have one responsibility.
What is another way to think about a responsibility?
A reason to change.
What is a sign that a class violates SRP?
It has more than one reason to change.
What should you do if a class has multiple responsibilities?
Split it into multiple more focused classes.
What are benefits of SRP?
Higher cohesion, better reusability, robustness, and understandability.
What is the Open/Closed Principle?
Classes should be open for extension and closed for modification.
What does closed for modification mean?
Avoid changing existing, well-tested source code.
What does open for extension mean?
Add new behavior by extending the system rather than rewriting old code.
Why is this useful?
Because changing existing code can introduce bugs.
What is wrong with PaintApp checking shape types directly?
New shape types require modifying PaintApp.
What is the better OCP-friendly approach?
Have Shape define draw() and let subclasses implement it.
What is the Liskov Substitution Principle?
Subtypes must be substitutable for their base types.
What does substitutable mean in LSP?
Code using the base type should still work correctly with a subtype.
What happens if a subtype cannot truly stand in for the base type?
The inheritance is badly designed and violates LSP.
Why is Board vs 3DBoard a problem for LSP?
Methods designed for a 2D Board do not naturally make sense for 3DBoard.
Why is Rectangle vs Square a classic LSP problem?
Code that expects to change width and height independently does not work properly for Square.
Why is “square is-a rectangle” not enough to justify inheritance?
Because the subclass must preserve the behavior expected of the base class, not just match a verbal category.
What is the biggest exam idea for SRP?
One class should do one focused job.
What is the biggest exam idea for OCP?
Add new behavior by extension, not by repeatedly modifying old code.
What is the biggest exam idea for LSP?
A subclass must truly behave like the base class wherever the base is used.