1/6
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
OOP 4 principles
abstraction
inheritance
polymorphism
data encapsulation
SOLID abbrev for?
SRP - single responsibility principle
OCP - open close principle
LSP - Liskov substitution principle
ISP - interface segregation principle
DIP - dependency inversion principle
SRP - single responsibility principle
avoids bloated classes - one class should have a single responsibility - a single reason to change
OCP - open close principle
A class should be open to extension and closed to change. → no need to retest old code, backward compatibility, adaptability
usually achieved through inheritance
LSP - Liskov substitution principle
Subclass should be able to substitute parent class → if subclass implements a method and throws UnsupportedMethodException, that will break this!
ISP - interface segregation principle
Avoids bloated interfaces. Implement only interfaces if all the methods from it are needed, otherwise break the interface apart.
DIP - dependency inversion principle
a high level class shouldn’t depend on a low level one. High level - declares the what, low level - declared the how, the details. Use Interface, abstraction instead if implementation dependencies
An abstraction shouldn’t depend on implementations. If an implementation needs new feature, you shouldn’t modify the base abstraction.