Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [solid]

Mnemonics for set of design principles: Single responsibility, Open-closed, Liskov substitution, Interface segregation, Dependency inversion

3
votes
2answers
206 views

Does method argument self-sanity checking violate the SRP?

I have a method login() which essentially sends a login request to a remote server. As I do not want to waste server resources on processing invalid data, I decided to consider sanity checking the ...
2
votes
2answers
179 views

Single responsibility principle - importer

I'm writing an importer, it should fetch some data from the database and put that data into appropriate places. Now the question is, should the importer itself fetch that data, or should that data(to ...
-1
votes
1answer
85 views

add new class that implement base interface but need one more parameter

I have few strategy class that calculate ranking. Those class implements interface with method scoreUpdates. Method scoreUpdates take two parameters( winners and lossers). Now i need add new ...
-2
votes
3answers
271 views

Are there any well known alternatives to the SOLID principles for OO programming? [closed]

I´m looking for some kind of better compilation of principles which takes the old basic concepts (DRY, KISS, etc...) and applies them to OOP related concepts like abstract clasess, interfaces etc... ...
4
votes
2answers
305 views

Interface Segregation Principle in Clean Architecture

In Chapter 10 of Clean Architecture, Martin gives an example for the Interface Segregation Principle. I have some trouble understanding that example and his explanations. In this example we have ...
46
votes
3answers
7k views

Using a “Pass-through (God) Service” is bad, right? [duplicate]

My team has developed a new service layer in our application. They created a bunch of services that implement their interfaces (E.g., ICustomerService, IUserService, etc). That's pretty good so far. ...
1
vote
1answer
116 views

Is it a good design to create an interface that inherits from multiple interfaces to reduce the amount of dependencies of a client?

I was refactoring an application to respect SOLID principles. When I was applying interface segregation I found the following case: interface A { void methodA(); void methodA2(); } ...
0
votes
1answer
522 views

Why does the Square–Rectangle problem violate SOLID principles?

My previous question was just with class diagram and because of some comments I thought I try to find an example with a little piece of code for the diagram to see if principles correct understood? ...
1
vote
2answers
375 views

Which SOLID principles are broken by this class diagram?

I just read about all the 5 principles S,O,L,I,D and I like test it in little example if I understand them correct. Which SOLID principles are hurt by this class diagram? I think what is broken is ...
1
vote
3answers
508 views

Convincing a development team to use a better design pattern [closed]

I recently joined a company where I was tasked with building a system for one of their clients. The work I've done is so far working well, but the most senior developer on the team who's been with the ...
1
vote
0answers
57 views

Should a UnitOfWork contain every Repository?

I'm trying to get the Repository/UnitOfWork pattern figured out. We're working on a project with EntityFramework and our DBContext contains 200+ tables. Right now our approach is to inject whatever ...
3
votes
2answers
114 views

Clarification about an example of the polymorphic open/closed principle

My question is regarding the polymorphic Open-Closed Principle. Say I have the following client: public class Client { private Server server; public Client(Server server) { this....
70
votes
4answers
7k views

Does following SOLID lead to writing a framework on top of the tech stack?

I like SOLID, and I try my best to use and apply it when I'm developing. But I can't help but feel as though the SOLID approach turns your code into 'framework' code - ie code you would design if you ...
1
vote
2answers
229 views

Liskov Substitution Principle

I am trying to wrap my mind around a Liskov Substitution Principle and I came across this article. SOLID Class Design: The Liskov Substitution Principle In this article, the author gives an example ...
1
vote
2answers
233 views

How to interpret Dependency Inversion Principle

I am working on trying to understand the SOLID object oriented design principles. I was able to get the "SOL" pretty easily, though "L" required some hand holding because I am bad at definitions. I ...
1
vote
1answer
170 views

to ISP or not to ISP?

I've got a design problem, and I figure it's not something totally uncommon so there must be some good practices out there. I have 2 domain entities: Process and Task. A Process is essentially a list ...
1
vote
0answers
234 views

Handling complex dynamic queries in Laravel 5

I am developing a project using Laravel. My workflow is: route directs to controller Controller calls eloquent models Eloquent models perform queries (tipically CRUD and find) Controller returns ...
2
votes
2answers
166 views

Changing Behavior - Special case in a loop

I have a module as below: def normalize(sub_item): pass def process(sub_item): pass def cleanup(sub_item): pass def calculator(item): pass def main(item): for index, sub_item ...
-1
votes
1answer
121 views

MVC / MVVM principles

I'm currently working on updating some old projects (inherited stuff) and I keep running into various small issues with the architecture. Namely monolithic classes too tightly coupled. One example ...
1
vote
0answers
86 views

What Design Pattern to use to render PDF pages for a PDF Proposal?

I want to create a set of patterns to use for rendering a PDF Proposal (a set of PDF pages). I have made a good start, but not clear on how to proceed when more complexity is involved. I am using ...
2
votes
1answer
59 views

Abstraction for Account transactions and balance

We have 10 applications which updates account balance table, without logging credit/debit line transactions (not sure why). They all have the pretty much same SQL Statement. In order to get out of ...
1
vote
1answer
304 views

Architecture / Design Pattern for Login Signup

I have a multi-seller ecommerce platform, derived out of Opencart 2.3. We changed quite a bit of the core code of the Opencart to add our own customizations, including features such as Seller ...
4
votes
2answers
224 views

Is it violation of single responsibilty to add a method to an existing API

Say i have a Rest API that has a POST and GET method. If i want to overwrite a resource in the API i can call the GET method to get the original item and then call the POST method to replace that ...
3
votes
4answers
423 views

Is Abstracting your code too much a bad use of SOLID Principles?

After an unresolved argument with a friend I decided to ask the stack overflow community. Is there something like abstracting your code too much? Which of the following is the better option. We come ...
1
vote
1answer
217 views

Domain driven design - factory with cross-cutting concerns

I was recently tasked with creating a factory that processes webhook events. Any authorized application in the solution (1 app per domain) can post any meaningful payload and as long as the event's ...
-1
votes
0answers
138 views

MVVM composite ViewModel for sharing fuctionality (instead of inheritance)

I'm looking for design ideas for something like a composite ViewModel. I'm facing a situation where a lot of ViewModels need CRUD operations and some need refresh operations. A minority of ViewModels ...
4
votes
1answer
445 views

Should unit of work create repository?

Our "unit of work" class has a method which takes a class type and creates a repository: public IRepository<TEntity> GetRepository<TEntity>() where TEntity : class { ...
-1
votes
1answer
147 views

Does Interface Segregation Principle apply to parameters/request objects?

I have recently seen an example of what I think is a clear violation of ISP, but my colleague argued it is easier to use. This is what happened: We had Options class that had 2 fields sent as a ...
30
votes
9answers
5k views

Designing a Class to take whole classes as parameters rather than individual properties

Let's say, for example, you have an application with a widely shared class called User. This class exposes all information about the user, their Id, name, levels of access to each module, timezone etc....
1
vote
2answers
217 views

Does it violate SRP to reject subclass method parameter

I was having a good read on Eric Lippert's blog about Wizard and Warriors. It suggests the creation of a Rules class, quote: We keep on talking about “rules”, and so apparently the business ...
1
vote
5answers
235 views

Single Responsability actor or use case?

I've been struggling to grasp my head around the SRP pattern, because I dont know if it refers to a actor o to the use case. In the following case: To don't violate the SRP, would you need to create ...
-1
votes
2answers
113 views

Reconciling the Interface Segregation Principle with the need to uniquely identify an object

I have an interface ICondition which only defines a single method, IsConditionMet This works well as it is the only information the parent entity needs from its conditions. However, there is a ...
7
votes
2answers
688 views

Liskov's substitution principle : If subtype has some extra behaviour implemented, which is not present in type, then is this violation of LSP?

In my quest to write better, cleaner code, I am learning about SOLID principles. In this, LSP is proving to be little difficult to grasp properly. My doubt is what if I have some extra methods in my ...
0
votes
1answer
87 views

Modeling web scraper

I'm working on a small application that is supposed to scrape/parse a few website and I'm wondering which would be the best way to achieve this (keeping DRY/SOLID in mind). Here's some pseudocode: ...
-2
votes
1answer
176 views

Can I use DI with client of Abstract Factory pattern c#

Let's say I have something like this: switch(i) { case 1: new Class1();break; case 2: new Class2();break; } So what's the best practices of doing this if in class where I placed ...
42
votes
8answers
11k views

Class that does not represent anything - is it correct?

I am just designing my application and I am not sure if I understand SOLID and OOP correctly. Classes should do 1 thing and do it well but from the other hand they should represent real objects we ...
3
votes
2answers
165 views

Command Query Separation. How to handle error handling for mutating functions returning void

I am learning about SOLID principles in a Pluralsight course where Command Query Separation is being discussed. I am fine with the query functions returning something (and crucially being non-mutating)...
-1
votes
1answer
159 views

OO Class Design for ATM card

I have to design a Class for ATM cards with the following attributes: Cardholder Name Card Number Pin Other than getters and setters, I have a method to validate the pin of the ATM. As per the ...
2
votes
2answers
170 views

Wrapping 3rd party objects that are dependant upon each other and best practices

I'm having a bit of a moment of indecision here and I'd like some perspective on it. I'm currently wrapping up objects from a 3rd party API (at home for my own project and at work), and I'm doing my ...
4
votes
1answer
115 views

Design pattern to instantiate implementations depending on properties

I have an interface: public interface MyInterface{} And two implementations: public class Imp1 implements MyInterface {} public class Imp2 implements MyInterface {} My program is a CLI. I want to ...
1
vote
0answers
286 views

What are a few arguments against SOLID principles? [closed]

I've been practicing SOLID in my code-base (PHP) as best as I could as of late and the progress is clear. Code is more readable, more maintainable and everything in-between. The problem is that I ...
4
votes
2answers
388 views

I'm struggling to see how dependency inversion doesn't lead to tighter coupling in lower level modules and less reuseability

I'm refactoring a project I did for my work and I'm trying to apply the SOLID principles to make the architecture cleaner. I've run into an issue with the Dependency Inversion Principle that I can't ...
7
votes
4answers
344 views

A few classes versus 20 classes? A question about bloat [closed]

In evaluating the work of an outsourcing company, I have found that they have a propensity for dividing work into as many classes as possible, each one being testable. In some ways this seems ...
2
votes
2answers
128 views

Is replacing the call to mutual exclusive methods by an injected strategy overengineering?

I recently gave advice to refactor some code along the lines of class Validator<T> : IValidator { public ValidationResult Validate(Validatable thingToValidate) { if(typeof(T)....
6
votes
5answers
1k views

What is more important? SOLID or KISS?

What is more important? SOLID or KISS? To be consistent with SOLID I would have to inject Decorator and Footer classes and create interfaces for them. public class HelloService { String name; ...
-3
votes
2answers
196 views

C#. Pattern for dynamic report creation

This is a simplified example, the actual problem has more reports and data points that are requested. Also, more reports could be added in the future so I would like to have something "smart" and ...
0
votes
0answers
80 views

Why does Qt consider disconnectNotify as violating the modularity of OOP?

Source It is stated that disconnectNotify is violating the OOP concept of modularity, why? Isn't it considered like LiveData of Android ? If it is really violating modularity, what was the ...
33
votes
6answers
7k views

Additional line in block vs additional parameter in Clean Code

Context In Clean Code, page 35, it says This implies that the blocks within if statements, else statements, while statements, and so on should be one line long. Probably that line should be a ...
0
votes
3answers
463 views

S.O.L.I.D. principles

I have a small question. Which approach is correct in the context of SOLID principles? 1 or 2 ? In the first case, the "CreateTask" method does not return the Task object, but places it on the list ...
4
votes
4answers
202 views

Software design strategy for a functionality that depends on a temporal situation

First of all please excuse my english mistakes; it's not my native language. Second, I couldn't find a better title to summarize my inquiry, so let me explain it below: Let's say we have a software ...