Questions tagged [solid-principles]

SOLID is an acronym for five principles of object-oriented design introduced or documented by Robert C. Martin. Use this tag on questions regarding any of the individual principles, or their relationships to other OOD concepts. Also use the five individual tags, when applicable.

The SOLID principles are language-agnostic principles of object-oriented design. (Not to be confused with tools and conventions for decentralized social applications proposed by Tim Berners-Lee and MIT.) In a series of articles in 1996, Robert C. Martin documented the existing Open-Closed and Liskov Substitution principles, and introduced the other three. Michael Feathers invented the acronym afterwards.

The acronym stands for:

References:

1149 questions
45
votes
5 answers

Writing JavaScript according to SOLID

Have any one used the SOLID programming principle (or any of it's parts) while developing JavaScript? I've just started up on reading on it but can't seem to find anyone that used it for JS. The only part I find easy to implement/use is the "Single…
fredrik
  • 17,537
  • 9
  • 51
  • 71
44
votes
12 answers

Are SOLID principles really solid?

The design pattern the first letter in this acronym stands for is the Single Responsibility Principle. Here is a quote: the single responsibility principle states that every object should have a single responsibility, and that responsibility…
Arseny
  • 7,251
  • 4
  • 37
  • 52
43
votes
3 answers

What is an example of the Single Responsibility Principle?

Can someone give me an example of the Single Responsibility Principle? I am trying to understand what it means, in practice, for a class to have a single responsibility as I fear I probably break this rule daily.
42
votes
5 answers

Can anyone provide an example of the Liskov Substitution Principle (LSP) using Vehicles?

The Liskov Substitution Principle states that a subtype should be substitutable for that type (without altering the correctness of the program). Can someone please provide an example of this principle in the domain of vehicles (automotives)? Can…
random512
  • 1,017
  • 3
  • 13
  • 19
41
votes
2 answers

Difference between OOP basics vs SOLID?

I know of OOP (Object oriented programming) and SOLID. OOP basics Encapsulation Abstraction Inheritance Polymorphism and SOLID Single Responsibility Principle Open / Closed Principle Liskov Substitution Principle Interface Segregation…
Ashish Sharma
  • 847
  • 1
  • 12
  • 23
40
votes
13 answers

How do you define a Single Responsibility?

I know about "class having a single reason to change". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility? Or could the real answer hide in YAGNI and only refactor to a single…
mmiika
  • 9,970
  • 5
  • 28
  • 34
36
votes
5 answers

Configuring Automapper in Bootstrapper violates Open-Closed Principle?

I am configuring Automapper in the Bootstrapper and I call the Bootstrap() in the Application_Start(), and I've been told that this is wrong because I have to modify my Bootstrapper class each time I have to add a new mapping, so I am violating the…
Omu
  • 69,856
  • 92
  • 277
  • 407
33
votes
3 answers

Dependency Inversion in Python

I've started to apply SOLID principles to my projects. All of them are clear for me, except dependency inversion, because in Python we have no change to define variable in type of some class inside another class (or maybe just I don't know). So I've…
29
votes
3 answers

The difference between liskov substitution principle and interface segregation principle

Is there any core difference between Liskov Substitution Principle (LSP) and Interface Segregation Principle (ISP)? Ultimately, both are vouching for designing the interface with common functionalities and introduce a new interface when you have…
28
votes
3 answers

Is Interface segregation principle only a substitue for Single responsibility principle?

Is interface segregation principle only a substitue for single responsibility principle ? I think that if my class fulfill SRP there is no need to extract more than one interface. So ISP looks like solution in case we have to break SRP for some…
27
votes
7 answers

What is the reasoning behind the Interface Segregation Principle?

The Interface Segregation Principle (ISP) says that many client specific interfaces are better than one general purpose interface. Why is this important?
26
votes
6 answers

Interface Segregation Principle- Program to an interface

I was reading about SOLID and other design principles. I thought ISP was the same as "Program to an interface, not an implementation". But it looks like these are different principles? Is there a difference?
26
votes
4 answers

Pattern for Creating a Simple and Efficient Value type

Motivation: In reading Mark Seemann’s blog on Code Smell: Automatic Property he says near the end: The bottom line is that automatic properties are rarely appropriate. In fact, they are only appropriate when the type of the property is a value…
ErnieL
  • 5,773
  • 1
  • 23
  • 27
26
votes
2 answers

Can you have an interface be dependent on a class?

I'm studying SOLID principles and have a question about dependency management in relation to interfaces. An example from the book I'm reading (Adaptive Code via C# by Gary McLean Hall) shows a TradeProcessor class that will get the trade data,…
Lews Therin
  • 3,707
  • 2
  • 27
  • 53
25
votes
8 answers

Monkey-patching Vs. S.O.L.I.D. principles?

I'm slowly moving from PHP5 to Python on some personal projects, and I'm currently loving the experience. Before choosing to go down the Python route I looked at Ruby. What I did notice from the ruby community was that monkey-patching was both…
Phillip B Oldham
  • 18,807
  • 20
  • 94
  • 134
1
2
3
76 77