lec 21: design principles: SOLID design principles, part 1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:17 PM on 4/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

27 Terms

1
New cards

What does SOLID stand for?

Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.

2
New cards

Which SOLID principles are covered in detail in this deck?

Single Responsibility Principle, Open/Closed Principle, and Liskov Substitution Principle.

3
New cards
4
New cards

What is the Single Responsibility Principle?

Every object/class should have one responsibility.

5
New cards

What is another way to think about a responsibility?

A reason to change.

6
New cards

What is a sign that a class violates SRP?

It has more than one reason to change.

7
New cards

What should you do if a class has multiple responsibilities?

Split it into multiple more focused classes.

8
New cards

What are benefits of SRP?

Higher cohesion, better reusability, robustness, and understandability.

9
New cards
10
New cards

What is the Open/Closed Principle?

Classes should be open for extension and closed for modification.

11
New cards

What does closed for modification mean?

Avoid changing existing, well-tested source code.

12
New cards

What does open for extension mean?

Add new behavior by extending the system rather than rewriting old code.

13
New cards

Why is this useful?

Because changing existing code can introduce bugs.

14
New cards

What is wrong with PaintApp checking shape types directly?

New shape types require modifying PaintApp.

15
New cards

What is the better OCP-friendly approach?

Have Shape define draw() and let subclasses implement it.

16
New cards
17
New cards

What is the Liskov Substitution Principle?

Subtypes must be substitutable for their base types.

18
New cards

What does substitutable mean in LSP?

Code using the base type should still work correctly with a subtype.

19
New cards

What happens if a subtype cannot truly stand in for the base type?

The inheritance is badly designed and violates LSP.

20
New cards
21
New cards

Why is Board vs 3DBoard a problem for LSP?

Methods designed for a 2D Board do not naturally make sense for 3DBoard.

22
New cards

Why is Rectangle vs Square a classic LSP problem?

Code that expects to change width and height independently does not work properly for Square.

23
New cards

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.

24
New cards
25
New cards

What is the biggest exam idea for SRP?

One class should do one focused job.

26
New cards

What is the biggest exam idea for OCP?

Add new behavior by extension, not by repeatedly modifying old code.

27
New cards

What is the biggest exam idea for LSP?

A subclass must truly behave like the base class wherever the base is used.