Explain the SOLID principles.
All five in short
- S — one reason to change.
- O — extend with new code, do not edit old code.
- L — a subtype does not break the base type's contract.
- I — narrow protocols; a client does not depend on what it does not need.
- D — depend on abstractions owned by the high level.
The overview with an example per principle is in the previous question. Here we go deeper into the two asked most often: SRP and DIP, because they decide whether your code is testable.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep