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
-1
votes
1 answer

Which SOLID and modern OO principles will be affected, and how, if we remove adherence to separation of concerns?

Say I break the principle of Separation of Concerns (SoC) and deliberately write, plan, and design my code to break, avoid and go against the SoC principle. What other OO and SOLID principles will necessarily be affected, and how? Is some SoC…
Dennis
  • 7,907
  • 11
  • 65
  • 115
-1
votes
1 answer

Implementing interface based on the chosen interface

So if I have an interface iConnection interface iConnection { } Which is implemented by: class OutlookConnection implements iConnection { } And class GoogleConnection implements iConnection { } And another interface iComparison interface…
Sinan Samet
  • 6,432
  • 12
  • 50
  • 93
-1
votes
1 answer

Single responsibility and methods

I think I might answer my own question here but lets say I understand the SRP on the method level to mean that a method serves one role. If I have methods that each individually cover one specific role in my class, but a method that uses lots of…
-1
votes
2 answers

Interface instance by id

We have different type of images, we store the image on disk in subfolders accordingly, and the metadata in database, including the fileTypeId. currently we have this: public enum FileTypes { Document=1, ProfileProto ... } and switch…
barii
  • 343
  • 1
  • 3
  • 12
-1
votes
1 answer

Interface definition for encapsulating a generic data source

I am currently working on a C# Plugin based design where the Plugin API methods will have access to a Context object which will contain the relevant information required for the method to work. In the current implementation, a file path is…
-1
votes
1 answer

Explanation of the D is SOLID principles using TypeScript

I was reading an article recently about the SOLID principles and I can't seem to understand the example about the Dependency inversion principle (DIP). The article gave the following example. First the incorrect way, then the correct way. INCORRECT…
Nick
  • 592
  • 6
  • 12
  • 21
-1
votes
1 answer

Classes and Methods in JAVA - Organising and SOLID principles

I'm very new to Java and i'm struggling a little with a project we've been set. I have to make a TicTacToe game, and it must contain 5 classes only : a driver class, GUI class, an abstract class for a computer player (randomly chooses between two…
-1
votes
1 answer

Two API's architecture, perform a request between them or duplicate code?

First of all, sorry for my bad english, I will try my best. I have two API's using the same database, in theory for distinct purposes, one for the user (edit profile, get user info...) and another for finance (store a payment, store an order...). I…
Lollorcaust
  • 23
  • 1
  • 5
-1
votes
1 answer

Spring data custom repositories and interface segregation principle

I'm working on my own model of repositories and I have this one: I'm following the Interface Segregation principle. I have a ReadRepository to define only read operations, PaginationRepository to add Pagination over the ReadRepository methods and…
Cristian García
  • 125
  • 1
  • 1
  • 8
-1
votes
2 answers

Does this violate single responsibility principle

Say i have a class like so: class Config { private $configA; private $configB; private $configC; private $configD; public function getConfigA(): string { return $this->confiA; } //... } In one sense this class has a…
-1
votes
1 answer

Does my code violates Single Responsibility Principle?

I'm making a console calculator as a test project. Main feature of my realisation of it is that i made digits and operators classes inherited from ITerm interface: public interface ITerm { Object Value { get; } } Now, i'm inheriting it in…
Occam's chainsaw
  • 189
  • 3
  • 14
-1
votes
1 answer

In the implementation of my interface A I want to return an instance of type interface B

I've been trying to work this out for a couple of days now and I need a little push in the right direction. The issue: I'm trying to build a simple log-in system in my web-application. I'm trying to make it so that there's loose coupling between my…
-1
votes
2 answers

Is it good to have enum implementation with processing logic?

In the below example Enums do the amount of processing that a class would do. enum TriggerHandlerType { DASHBOARD { @Override TriggerHandler create() { return new DashboardTriggerHandler(); } }, …
Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
-1
votes
2 answers

adding elements to an attribute which type is a generic java collection

Assuming that IUncle is an interface that Uncle implement. Assumming that I don't wont to use concrete classes inside the class Child because I want Child to be use with any implementation of Iuncle. How can I change the implementation of Child…
mokolop
  • 11
  • 1
  • 3
-1
votes
1 answer

dependency inversion principle vs factory pattern in C#

Is there any difference between those two? I am trying to learn those topics and both looks same concept. In Factory pattern we will create FactoryClass which will be responsible for creating objects of other class (removing dependency). I believe…
Techie
  • 11
  • 4