SOLID & OOP Principles (50 Qs)•Part 1: Core SOLID Principles & Fundamentals (1 - 10)
What are the SOLID Principles and why are they fundamental to software engineering?
junior LevelCode Examplesolid-principlesCore SOLID Principles
In Simple Words: SOLID is an acronym for 5 object-oriented design principles introduced by Robert C. Martin (Uncle Bob):
- S - Single Responsibility Principle (SRP): A class should have one, and only one, reason to change.
- O - Open/Closed Principle (OCP): Software entities should be open for extension, but closed for modification.
- L - Liskov Substitution Principle (LSP): Subtypes must be substitutable for their base types without altering program correctness.
- I - Interface Segregation Principle (ISP): Clients should not be forced to depend on methods they do not use.
- D - Dependency Inversion Principle (DIP): Depend upon abstractions, not concretions.
- Goal: Prevents code fragility, rigid coupling, and technical debt as codebases grow.
text
SOLID Principles:
┌───┬──────────────────────────────────┬─────────────────────────────┐
│ S │ Single Responsibility Principle │ One class, one responsibility│
│ O │ Open/Closed Principle │ Open to extend, closed to edit│
│ L │ Liskov Substitution Principle │ Subtypes don't break contracts│
│ I │ Interface Segregation Principle │ Small, client-specific APIs │
│ D │ Dependency Inversion Principle │ Depend on interfaces, not code│
└───┴──────────────────────────────────┴─────────────────────────────┘