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

How to use WebApi along with MVC 5 in Student - course model - ASP.NET

I have experience of developing ASP.NET-MVC application and learning WebApi very recently. I understood that action method in API are HTTP, hence can directly the resulting model. I am also aware that I can use MVC along with WebApi, my struggling…
K.Z
  • 5,201
  • 25
  • 104
  • 240
-1
votes
1 answer

Where to register dependency injection when have multiple projects?

I should register DI. private static void Initialize(ContainerBuilder builder) { builder.RegisterType().As().SingleInstance(); //... } And this is clear to me. But what if I have 17 projects in my…
Raskolnikov
  • 3,791
  • 9
  • 43
  • 88
-1
votes
1 answer

Best way to design class for web service calls

I have around 10 web service calls and I made the single static class where I have put all the calls in the same class class WebserviceCalls { public static function getReportDetails($reportId) {} public static function getUserSession($userId)…
prabeen giri
  • 803
  • 7
  • 18
-2
votes
2 answers

How to sort vector of structs by given field?

I need to sort vector of structures by a given field. To anyone who faces the same problem: I just made my own sort function and there you can pass in lambda as many variables as you want(not only two of them). Here I used a lambda expression, but…
Umar Bhat
  • 39
  • 3
-2
votes
3 answers

How to refactor two classes doing the same thing except one method to make them more OOP-friendly?

i have problem about design a module of my project. Lets say, you have two classes which both of them almost doing the same thing. You can think like DeviceManager. Both of them connect/disconnect/parse exactly the same way. After parse the message…
Hasan Durukan
  • 83
  • 1
  • 7
-2
votes
1 answer

Thinking in SOLID principle during the design process

I'm new to SOLID principle and design, I understand the principle however, I have a hard time knowing where to start the design process. I understand that design is an iterative process, what step or question you ask yourself during the design…
Claude
  • 371
  • 1
  • 4
  • 16
-2
votes
2 answers

Did I get over engineering?

Consider the code snippet : switch (sectionType) { case "AConfig": maxSize=config.Value.AConfig.MaxSize; break; case "BConfig": maxSize = config.Value.BConfig.MaxSize; break; case "CConfig":…
farshid
  • 51
  • 1
  • 7
-2
votes
1 answer

how to get employee using optimal way by id,name ,exp

i have written below code without applying any design pattern,Is anything wrong in this code. class Employee { public int EmployeeID { get; set; } public int YearOExperience { get; set; } public int Salary { get; set; } …
And
  • 5
  • 5
-2
votes
3 answers

What is the best practice to handle if true then run?

function handleOrder(data) { if (data.payment_type === 'VISA') { handleVisaPayment() } if (data.payment_type === 'VISA') { handleMastercardPayment() } if (data.payment_type === 'PayPal') { …
-2
votes
1 answer

Split C# code into 2 methods to be more SOLID

Im trying to rewrite my current piece of code into (see example0. But it doesnt know the carriage animal in my CheckIfAnimalFits method. How would I fix this without moving the entire foreach into the method Current code public bool…
Im__Ruben
  • 9
  • 6
-2
votes
2 answers

Solid Principles / Builder Pattern

I am creating a very small application to demonstrate solid principles and also a brief implementation of a builder pattern, does anyone have any feedback as to how this could be improved or how it breaks the solid principles? The app is a small app…
-2
votes
1 answer

I'm having trouble understanding SOLID principles

I could really use some help with this one. I'm trying to use SOLID principles in my next php project but i'm having a really tough time understading it. First of all, i can't really grasp single responsibility principle. Let's say i'm creating…
bici
  • 11
  • 3
-2
votes
1 answer

I'm confused about how encapsulation should work

Hi. Today I wanted to play with concepts of good OOP design and I tried to write an application for a movie store where customers can buy movies from movie store. I have three classes in it. A class that represents a movie store and a class for…
-2
votes
1 answer

Implement multiple functions in one method

I am new to solid principle. I think i'm violating this kind of implementation: class Students{ public void Save(int id){ if(id !== 0){ //add students here... }else{ //edit student details…
CherryBlossom
  • 393
  • 4
  • 8
-2
votes
1 answer

Should I create an interface for a simple abstract class?

It happens quite often that I have an abstract class that is pretty much an interface, save for a few trivial methods (say an average(array) method). In these cases, does it make sense to create an interface, so that the abstract class implements…
lfk
  • 2,423
  • 6
  • 29
  • 46
1 2 3
76
77