AI-generated summary
Single Responsibility Principle (SRP): A class should have only one reason to change, meaning it should only be responsible for one task. For example, a Person class should only handle tasks related to a person and not unrelated tasks.
Open-Closed Principle (OCP): Software entities should be open for extension but closed for modification. For example, defining a shape class and allowing different types of shapes to inherit from it without modifying the shape class itself.
Liskov Substitution Principle (LSP): Subclass objects should be able to replace all instances of superclass objects.
Interface Segregation Principle (ISP): Clients should not depend on interfaces they do not need, meaning interfaces should be small and specific.
Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules, both should depend on abstractions; abstractions should not depend on details, details should depend on abstractions. For example, a company class containing a department class should consider using composition instead of inheritance.
Law of Demeter: An object should have minimal knowledge of other objects and only interact with its immediate friends.