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
0
votes
2 answers

Ending with too many objects (layered design)

I have a lot of dropdown lists, custom grids on my webform which are displayed to the end user. Each is populated from database through a DAL. I have separate classes defined for each. However, I am thinking about reducing the number of classes, as…
Zo Has
  • 12,599
  • 22
  • 87
  • 149
0
votes
1 answer

violation of SOLID principles

suppose we have a class structure where the code is divided in two parts lets us say computer science and business, now this also further divides in terms of country also, say Indian (cs or MBA) and US (cs or MBA). now let us consider a…
Anil Sharma
  • 558
  • 6
  • 18
0
votes
5 answers

How such an important principle "OCP" will be the reason of massive code duplication practice?

OCP (Open/Closed Principle) is one of the SOLID principles. Which is says: ”Software Entities should be Open for Extension, but Closed for Modification.” It take me while to understand the above sentence about OCP. And when I start read more about…
egyamado
  • 1,111
  • 4
  • 23
  • 44
0
votes
2 answers

Which class does a better 'Separation of Concerns'

I have this class, which creates a document and saves it: public class DocCreator { private IDocumentStore _documentStore; public DocCreator(IDocumentStore documentStore) { _documentStore = documentStore; } public void…
user369117
  • 775
  • 1
  • 8
  • 19
0
votes
3 answers

Do out parameters in methods on a stateful object add responsibilities?

I have an object that's responsible for sending email, so I create an EmailSender, then tell it to SendEmail, passing in some EmailDetails: string diagnostics; EmailSender sender = new EmailSender(); try { sender.SendEmail(details); …
MStodd
  • 4,716
  • 3
  • 30
  • 50
0
votes
1 answer

Does the class CommaDelimLog in the following code violates single responsibility principle?

The program parses log files - each log file may have different kind of field format (fixed width, comma delimited, etc). Also each log file are mixed of several different kind of logs - each kind have different field definition). For example, the…
0
votes
2 answers

Is it good or not to have temporary fields to save costly work between modules

I have: Raw Object: contains raw data before importing to the system Module #1: Validator which will validate Raw Objects Module #2: Updater which will use validated raw data (invalid data were removed) to generate Real Objects Module #1 has to…
Thang Tran
  • 137
  • 3
  • 6
0
votes
2 answers

Single Responsibility Principle: Should I separate my bibliography class in Reader, Writer and Container class?

cowboy coder needs some help from SO-veterans: I have a given application that uses a bibliography which is read from a file (in reality, it can be different files but let's assume a single file only). I build a new application that should use the…
0
votes
1 answer

Open-Closed Principle and Builder pattern

Can anyone share sample of using Builder pattern to confirm OCP (Open-Closed Principle). Which else patterns are linked with OCP?
ASD
  • 725
  • 3
  • 10
  • 19
0
votes
1 answer

how should i validate data

i'm creating a shopping website using asp.net and Model View Presenter pattern and the architecture is layered. i know that i should have validator classes that are responsible for validating user inputs in business layer and i also should have…
jim
  • 494
  • 2
  • 5
  • 23
-1
votes
1 answer

What is the best design of getting derived class property?

class Item { // public: // virtual int GetDamage() const { return -1; } }; class Weapon : public Item { public: Weapon(int InDamage) :Damage(InDamage) { } int GetDamage() const { return Damage; } // virtual int…
RobsBiz
  • 9
  • 2
-1
votes
1 answer

How far to push the SOLID principles in an app following DDD philosophy

I'm working on a domain-driven design PHP application that will last for years and that will have many modifications and new features. This is the first time I am developing trying to follow the different concepts of DDD, and I am also using CLEAN…
-1
votes
1 answer

Object-oriented paradigms (SOLID) violated in Python? (example: subclassing of tuple to implement FractionTuple)

I was quite surprised to see that Python - at least partially - seems to violate some oo / SOLID principles. Example: class FractionTuple(tuple): def __new__(cls, p, q): # Ensure that p and q are integers if not isinstance(p, int) or not…
TomS
  • 216
  • 1
  • 7
-1
votes
1 answer

SOLID priciples - Single Responsible is just about composition or also dependency inversion?

I have seen examples online about the Single Responsible principle. They always use IoC/DI as an example. They move the code from class A to class B and pass class B as reference. See code below: class B {} class A { b; // reference used …
Znar
  • 193
  • 12
-1
votes
1 answer

Reference Error: calling class method in super() typescript

I am not able to call someMethod, it gives error ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor\ class BaseClass{ //some properties here I want to return whoever extends…
Danyal Shahid
  • 136
  • 1
  • 8