SOLID - programming principles

Jetzt loslegen. Gratis!
oder registrieren mit Ihrer E-Mail-Adresse
S.O.L.I.D. von Mind Map: S.O.L.I.D.

1. S

1.1. Single Responsibility Principle (SRP)

1.1.1. “A class should have one, and only one, reason to change.”

1.1.2. Think of this as a warning not to create god objects that try to do too many different things.

2. O

2.1. Open-Closed Principle (OCP)

2.1.1. “You should be able to extend a classes behavior, without modifying.”

2.1.2. This is all about using polymorphism and abstraction to build new functionality.

3. L

3.1. Liskov Substitution Principle (LSP)

3.1.1. “Derived classes must be substitutable for their base classes.”

3.1.2. The idea behind this principle is that code should be written such that if you create a new derived class from a base class you should not have to modify code to work with this derived class.

4. I

4.1. Interface Segregation Principle (ISP)

4.1.1. "No client should be forced to depend on methods it does not use."

4.1.2. ISP splits interfaces that are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them.

5. D

5.1. Dependency Inversion Principle (DIP)

5.1.1. “Depend on abstraction, not on concretions.”

5.1.2. Dependency Inversion is all about building classes that are created to use abstractions of 3rd party objects so that the concrete objects can be changed at will without needing to rewrite your code.

6. SOLID is not a panacea and you should not dogmatically follow it.

6.1. Blindly following principles is something that young and inexperienced developers often do, they learn of a new methodology or tool that seems like a good idea and they attach to it and try to use it for everything, even when it doesn’t make sense.