Core Java 12: SOLID Principles Flashcards

(6 cards)

1
Q

SOLID Design Principles

A

A set of guidelines for making code more reusable and reliable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SRP

A

Single Responsibility Principle: A class should have only one reason to change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

OCP

A

Open-Closed Principle: Open for extension, closed for modification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

LSP

A

Liskov Substitution Principle: Subtypes must be substitutable for their base types. Penguin’s fly() method would throw an error if fly() is built into Bird. Instead create a separate FlyingBird class inheriting from Bird.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ISP

A

Interface Segregation Principle: Don’t force clients to depend on methods they don’t use. Keep interfaces small.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DIP

A

Dependency Inversion Principle: High-level modules should not depend on low-level modules.
Both should depend on abstractions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly