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
551
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 ...
0
votes
2
answers
346
views
C# - Entity handler correct use clean code
I have a question about setting up my service. My main concern is if the design is clean and in order. Whether it meets the SOLID principles and does not spill out on me.
I have entities like order ...
3
votes
7
answers
564
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,...
4
votes
3
answers
3k
views
What is a SOLID way for creating objects dynamically using a factory?
Description
I want to create an instance of an object at runtime, however, the parameters used to create the object are not always the same. To help explain, I have created a simplified example (in ...
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....
1
vote
1
answer
458
views
3rd party REST API calls in repository pattern
For a long time, I’ve been using Repository pattern to abstract data access logic from actual business logic, always using SQL or noSQL databases as my data source.
But how much valid is it, to ...
0
votes
1
answer
260
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 ...
5
votes
7
answers
587
views
Exceptions and the Liskov Substitution Principle
Consider the following scenario.
I have an interface IService:
public interface IService
{
void DoSomething();
}
with an implementation:
public class Implementation : IService
{
// This might ...
1
vote
3
answers
269
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 ...
3
votes
2
answers
266
views
Trade-offs between applying the open-closed principle and type safety
There's lots of questions about the open-closed principle here, but none that I found satisfied this particular problem. At $job, I'm teaching my team Rust, but I believe the nature of this question ...
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
2
answers
418
views
Invariant rule in Liskov Substitution Principle
From Liskov Substitution Principle, I am still not very clear about the invariant rule. I read through many posts but I still have doubts.
My example is picked from this blog, the example is slightly ...
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 ...
2
votes
2
answers
2k
views
Is this design too convoluted?
I'm trying to experiment with SOLID in order to get a better grasp of its' concepts. With that in mind, I'm making a card game project.
There's a GameUtils project that contains the following classes:...
-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 ...