Phase 5 of 9 · 9 lessons
Low-level design: OOP and SOLID
The building blocks of good class design: the four pillars of OOP, composition over inheritance, the five SOLID principles, class diagrams, and the concurrency basics LLD questions expect.
Low-level design is about code that's easy to change. SOLID is a set of reasons to split or join classes; patterns (next phase) are proven shapes that follow those reasons. Learn the 'why' here, and the patterns will make sense.
Lessons, in order
-
5.1
OOP: the four pillars
Object-oriented programming organises code into objects that bundle data and behaviour. Its four pillars are encapsulation, abstraction, inheritance and polymorphism.
-
5.2
Composition over inheritance, and interfaces
Composition means building a class out of other objects it has ('has-a'), instead of inheriting from a parent ('is-a').
-
5.3
SOLID: S — Single Responsibility Principle
A class should have one reason to change: one job.
-
5.4
SOLID: O — Open/Closed Principle
Code should be open for extension but closed for modification: add new behaviour by adding code, not by editing code that already works.
-
5.5
SOLID: L — Liskov Substitution Principle
Objects of a subclass must work anywhere the parent class is expected, without breaking the program.
-
5.6
SOLID: I — Interface Segregation Principle
Clients shouldn't be forced to depend on methods they don't use. Prefer several small, focused interfaces over one big one.
-
5.7
SOLID: D — Dependency Inversion Principle
High-level code should depend on abstractions, not on concrete low-level details.
-
5.8
UML class diagrams and relationships
A class diagram shows the classes, their fields and methods, and how they relate to each other.
-
5.9
Concurrency basics: threads, locks and race conditions
Concurrency is several tasks making progress at the same time. A race condition is a bug where the result depends on the exact timing between them.