Fundamentals / Principles Flashcards
CS Fundamentals
What are the principles in the SOLID acronym?
Single responsibility Open-closed Liskov substitution Interface segregation Dependency inversion
CS Fundamentals
Define (SRP) Single responsibility principle
Software entities should have only a single responsibility.
i.e. only one potential change in the software’s specification should be able to affect the specification of the class.
MOST IMPORTANT!
CS Fundamentals
Define (OCP) Open/closed principle
Software entities should be open for extension, but closed for modification.
CS Fundamentals
Define (LSP) Liskov substitution principle
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
CS Fundamentals
Define (ISP) Interface segregation principle
Many client-specific interfaces are better than one general-purpose interface.
CS Fundamentals
Define (DIP) Dependency inversion principle
Depend upon Abstractions. Do not depend upon concretions.
Think: Dependency injection (DI)