Questions tagged [solid]
Mnemonics for set of design principles: Single responsibility, Open-closed, Liskov substitution, Interface segregation, Dependency inversion
406 questions
7
votes
3
answers
546
views
What SOLID principles does the Java List interface challenge?
The Java List<E> interface includes methods, such as add(E) and remove(Object), that work as the names suggest on instances of mutable concrete implementations, such as ArrayList<E> and ...
3
votes
7
answers
555
views
Do I need to create an interface for every service class to follow good design principles?
I'm working on a custom Magento 2 module in my internship, and I'm trying to follow SOLID principles in my code.
Right now, my controller actions handle everything: getting request data, processing it,...
5
votes
4
answers
958
views
Is the SRP of SOLID (or any) principle relevant to the grouping of packages?
Specific example question:
I am writing multiple different software packages, in different repos, that each do different things. Many of these packages produce something that we want to visualise/plot....
0
votes
1
answer
255
views
Best approach to map user roles dynamically in ASP.NET Core Identity register method?
I'm working on an ASP.NET Core application that uses Identity for user management. I have an AccountService with a Register function, where I accept a RegisterBaseDto that contains the role ...
1
vote
3
answers
268
views
In "Liskov Substitution Principle", is "invariants can't be weakened in a subtype" a kind of "postconditions can't be weakened in a subtype"?
According to Invariant rule in Liskov Substitution Principle, I know one of the form of violation of "Liskov Substitution Principle" is violating "invariants can't be weakened in a ...
0
votes
2
answers
147
views
Dependency injection - passing responsibility for dependency to a Client?
I have long standing argue about dependency injection and SOLID principles with my teammate. We both want to make an Exporter, to export data into various formats.
My approach (in PHP):
class Exporter ...
3
votes
4
answers
272
views
Does interface segregation principle apply to configuration data holders?
If you have a class representing your applicative config file.
Instead of injecting that config class everywhere, would it be good application of interface segregation principle to expose several ...
-1
votes
1
answer
170
views
Will I lose confidence of my code working in mocking dependency injected services? [duplicate]
Let's say that I have a class with a service that is going to be injected at runtime:
class Thing {
private magic: IMagic; // Magically injected service
public doStuff(){
// Do a lot ...
2
votes
5
answers
614
views
What exactly is the single responsibility principle? [duplicate]
I've generally understood the SRP to roughly mean:
Each class should do one thing
Exactly what "one thing" is is up for debate.
However, I've recently seen claims that the entire SRP has ...
1
vote
3
answers
116
views
Refactoring Controllers publishing different events with MediatR library
I have Controller that basically publishes different Event based on some input criteria, simplified version of the logic is here:
[HttpPost]
public async Task<ActionResult> Create(...
2
votes
2
answers
451
views
In "Liskov Substitution Principle", are "Preconditions can't be strengthened in a subtype" & "Postconditions can't be weakened in a subtype" the same?
According to Is this a violation of the Liskov Substitution Principle?, as I understand, the top answer currently says the code below is violating "Liskov Substitution Principle":
public ...
2
votes
1
answer
2k
views
Clean architecture - how to manage use cases that depends on external apis
How to apply clean architecture concepts in a software that depends on External APIs.
Example:
A business that offers some kind of subscription to its users.
Its convinient to store some subscription ...
1
vote
4
answers
409
views
Is there any intent behind SRP other than SoC
Edit based on responses so far
I am starting with an edit so as to save future contributors from going down the same path others have.
I am only interested in contributions that stick to the exact ...
4
votes
1
answer
293
views
What is the anti-pattern for modules that group objects of the same type? [closed]
In MVC, I often seen all models in a models.py module, all views in a views.py module, and the controller - you guessed it - in a controller.py module. In other projects, I sometimes see all exception ...
5
votes
4
answers
577
views
Does my outer class adhere to the Single Responsibility Principle?
I often write front end apps with a generic MVC pattern. I use javascript but this questions is language independent and relates to OOP as a whole. I struggle to understand the SRP principle and I ...
3
votes
1
answer
296
views
Interface segregation principle
Let's say we have the following business requirements:
We have a list of dishes. They have a name and a list of ingredients. The restaurant owner always wants to have a dish (and only one) marked as ...
0
votes
1
answer
579
views
Best way to name derived classes when extending its functionality [closed]
I have just recently joined a new company and one of the classes used to log information has not been written properly. So I have been asked to add new functionality to the logger.
Rather than ...
10
votes
3
answers
4k
views
Why is having bloated interfaces an anti pattern?
[I'm using the term interface here with C#'s interface in mind. I won't tag the question with a C# tag because it really isn't a C# question.]
In my work we do unit and integration tests but we don't ...
1
vote
1
answer
2k
views
Clean code and SOLID principles in WPF/MVVM view models?
I'm currently reading "Clean Code" by Robert Martin (which I should have read years ago), and it's given me a bit of a wakeup call, especially regarding keeping methods and classes small, ...
3
votes
3
answers
487
views
Is there any redundancy within the scope of SOLID principles?
I have read in an article DIP in the Wild that
"When Robert Martin first discussed the DIP, he equated it a first-class combination of the Open Closed Principle and the Liskov Substitution ...
14
votes
5
answers
4k
views
What would be an example of the Liskov Substitution Principle, if you don't use inheritance?
I am reading about the SOLID principles, but it seems like the Liskov-Substitution Principle primarily refers to programs that use inheritance.
From my understanding people are shifting more towards ...
0
votes
3
answers
165
views
What should be the optimal management of end user messages in N-tier architecture?
I'm curious about your thoughts on this subject that we have discussed with the people around me. Especially at the architectural stage, in which layer is the most optimal and efficient way to use the ...
1
vote
2
answers
119
views
How to improve the design of the code using tools (e.g. git)?
There is a bunch of books that state principles about good code (SOLID, DRY, Design patterns etc.) Those principles are solutions to some problems. An application of those principles could go like ...
1
vote
1
answer
369
views
Wrapping methods without Decorator Pattern or AOP
I have a Dao interface which doesn't have any methods defined.
Then I have multiple classes which implement this interface, like PetDao and HouseDao.
For some of the implementation classes, and some ...
0
votes
2
answers
140
views
By applying the ISP are we bound to segregating the class too?
So basically the ISP states we should break big interfaces with members that are not cohesive with each other to smaller and more cohesive interfaces, which is very close (if not the same) to what is ...