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

learn more… | top users | synonyms

0
votes
1answer
55 views

Non-anemic model and SRP

I'm implementing a feature in legacy system right now. Instead of putting all my logic in some dummy application services and having anemic models, I thought I will try to do some OOP this time. I'm ...
5
votes
2answers
160 views

How to avoid “type dispatchers” when working with SOLID

I've realized that since I've been more and more strict about the SOLID principles, my code tends to consist of more pure data objects and a lot of "operator" classes which seems to go against ...
0
votes
3answers
407 views

Gathering IP address and workstation information; does it belong in a state class?

I'm writing an enterprisey utility that collects exception information and writes to the Windows Event Log, sends an email, etc. This utility class will be used by all applications in the corporation: ...
2
votes
3answers
280 views

Inheritance in imperative programming

My first introduction to programming was Java, which was horrible so I learnt Actionscript3 which was nice... "The point is" OOP was my introduction to programming where by I went on to gain a career ...
4
votes
3answers
236 views

Reducing dependency cycles and reducing coupling

I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine. ...
4
votes
3answers
264 views

DDD, modularizing the application and domain layers without breaking the DIP

Quoting DDD theory: The application layer is thin in terms of domain logic - it merely coordinates the domain layer objects to perform the actual work. When it comes to modularization, and ...
2
votes
2answers
209 views

Implementation Coupling

This question is regarding Interface Segregation Principle Best-Practices. I use abstract examples below, but the question arises from actual code I've seen that performs what I can only call ...
3
votes
2answers
246 views

Does this Decorator implementation violate the Liskov Substitution Principle?

Please consider the following implementation of the Decorator design pattern: WordBank objects store strings and return them to the client through the method getWords(). The decorator class, ...
3
votes
0answers
49 views

Is this code solid? If it's not why not? And how should the dependencies be managed? [closed]

I am very interested in following the SOLID principles of writing code, but for the life of me I consistently run into more questions than answers. One of the questions I have now related to the code ...
1
vote
1answer
61 views

How to organize all classes derived from SRP?

As the SRP says, the way to achieve this principle is divide all into smaller. And what you have just made small, make more smaller. As consequence we got more files and my question is about it, how ...
2
votes
1answer
232 views

My first SOLID re-factoring

I am trying to make use of SOLID principles for the first time. I am re-factoring a File class that stores file information and makes file operations available. This class is then inherited to ...
0
votes
0answers
109 views

Dependency Inversion Principle

I have been studying also S.O.L.I.D. and watched this video: https://www.youtube.com/watch?v=huEEkx5P5Hs 01:45:30 into the video he talks about the Dependency Inversion Principle and I am scratching ...
3
votes
2answers
263 views

How do you apply Single Responsibility principle to a repository

I am trying to apply "SOLID" whenever I can and try to use common sense and avoid a pattern when I see that a pattern is creating more problems than it's trying to solve. I don't want to apply a ...
25
votes
8answers
2k views

What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP. I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit ...
0
votes
1answer
76 views

Extending a class for debugging: public API, hidden implementation or something else?

I'm working on a fairly large project that involves 3D drawing, and I want to add some visualizers (for example, to see the bounding boxes of the objects) to make debugging easier. However, I'm having ...
4
votes
2answers
154 views

Does having many duplicated methods and deep inheritance hierarchies in GUI APIs (Java Swing, Android SDK) violate the SOLID design principles?

For those unfamiliar with the SOLID principles you can start reading here: Wikipedia article. However, most of my understanding comes from: http://www.objectmentor.com/resources/publishedArticles.html ...
26
votes
6answers
4k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
36
votes
5answers
4k views

IOC Containers break OOP Principles

What is the purpose of IOC Containers? The combined reasons for it can be simplified to the following: When using OOP/SOLID Development principles, Dependency Injection gets messy. Either you have ...
1
vote
1answer
192 views

Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email: private static class EmailHelper { public static void SendEmail(string from, string to, string subject, string message) { ...
1
vote
3answers
165 views

Am I violating LSP if the condition can be checked?

This base class for some shapes I have in my game looks like this. Some of the shapes can be resized, some of them can not. private Shape shape; public virtual void SetSizeOfShape(int ...
27
votes
3answers
16k views

Programming SOLID Principles

Over time I could understand two parts of SOLID – the “S” and “O”. “O” – I learned Open Closed Principle with the help of Inheritance and Strategy Pattern. “S” – I learned Single Responsibility ...
3
votes
3answers
503 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
15
votes
2answers
2k views

Equivalent of SOLID principles for functional programming

I've found the SOLID principles quite useful when thinking about object-oriented design. Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?
1
vote
2answers
117 views

Databases and the single responsibility principle

Can the single responsibility principle be applied to databases? relational databases I mean. I'm asking this because a typical database will have several tables and we may find something like that ...
2
votes
1answer
225 views

Design Patterns for creating tasks

I am developing software where each action in my entities need create tasks that will be execute in my infrastructure. When I create a task it is only records in the database. Afterwards, a windows ...
3
votes
4answers
724 views

Is it good practice to declare and set properties in abstract classes?

I am using PHP and designing some abstract classes. I can declare properties with constant values within my abstract class and access/overwrite them from any class which extends this without re ...
1
vote
1answer
175 views

Handling array passed to object at creation

When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array ...
2
votes
1answer
110 views

Liskov substitution principle with abstract parent class

Does Liskov substitution principle apply to inheritance hierarchies where the parent is an abstract class the same way if the parent is a concrete class? The Wikipedia page list several conditions ...
6
votes
3answers
403 views

How to adhere to the open-closed principle in practice

I understand the intent of the open-closed principle. It's meant to reduce the risk of breaking something that already works while modifying it, by telling you to try to extend without modifying. ...
1
vote
2answers
219 views

How to refactor code that has 2 concerns

Say I have this code: if ($this->ship == "e") { $this->price->addLine($this->price->base * $this->price->e, 0, "Export"); ...
74
votes
13answers
7k views

Why would Square inheriting from Rectangle be problematic if we override the SetWidth and SetHeight methods?

If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design? I have heard people say: If you made Square derive from Rectangle, then a Square ...
0
votes
2answers
172 views

High-Level Classes and Low-Level Classes [duplicate]

I've seen at SOLID there is a principle Dependency inversion principle. Also I've seen that: High-level Classes should not depend on Low-level Classes but both of them should depend on abstractions. ...
3
votes
2answers
396 views

Aren't decorators easily breaking the ISP?

"The Interface-Segregation Principle (ISP) states that no client should be forced to depend on methods it does not use." The decorator pattern is a design pattern to decorate a method of a class. For ...
0
votes
3answers
727 views

Avoiding coupling

It is also true that a system may become so coupled, where each class is dependent on other classes that depend on other classes, that it is no longer possible to make a change in one place ...
35
votes
11answers
4k views

Ensure that each class has only one responsibility, why?

According to Microsoft documentation, the Wikipedia SOLID principe article, or most IT architects we must ensure that each class has only one responsibility. I would like to know why, because if ...
0
votes
0answers
168 views

API Client Design

I'm designing a client to the Tomtom WEBFLEET.connect API in PHP. (You can read more about the API through the full documentation here: ...
10
votes
5answers
886 views

Are there flavours of OOP where some or all of the SOLID principles are antithetical to clean code?

I recently had a discussion with a friend of mine about OOP in video game development. I was explaining the architecture of one of my games which, to my friend's surprise, contained many small ...
1
vote
0answers
128 views

How much segregation is too much in this design?

We are working on ASP.NET webforms application developed using WCSF (MVP pattern). In the application, there is a search screen that allows the user to enter some fields and display the results. We ...
1
vote
2answers
161 views

Dealing with an often occuring dependency that is not related to the class

I'm using view classes for my templating. These view classes often require the Routing class to get URI's from other pages. You could actually say that the Routing should be available to every view ...
3
votes
2answers
529 views

Implementing the Interface Segregation Principle

Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition: public interface IConvertible { TypeCode GetTypeCode(); bool ...
9
votes
2answers
327 views

Too many CS files in a single project [duplicate]

I am working on a ‘brown-field’ project, with a team of programmers. I understand each programmer will have different styles. I am running into some criticism with my coding style, specifically ...
0
votes
0answers
120 views

Customizing configuration for PHP will Laravel 4 IoC be useful?

This topic has been discussed in this post: Customizing configuration with Dependency Injection However - I couldn't find one for PHP syntax and since one of the answers was to use a specific ASP.net ...
9
votes
6answers
2k views

What makes the difference between “Hire” and an honest “almost” for final on-site interviews? [closed]

So, I have recently had on-site interviews with Google and Amazon and received polite rejection letters letting me know I was close, but not quite right for the skills they were looking for. I've ...
2
votes
1answer
218 views

Is more dependency inversion always better?

Is there any situation in industrial object-oriented programming when the dependency inversion principle should not be used?
1
vote
2answers
450 views

Interface Segregation Principle - type hinting multiple interfaces

The question is about typehinting of the role interfaces. The code example has two DataMappers which typehint the interface they need in the constructor, FooDataMapper type hints the Preparable ...
2
votes
2answers
193 views

Achieving multiple tasks within one loop

With relation to what's considered good OOP engineering principles, SOLID, DRY, KISS etc I am wondering whether to complete multiple tasks within one loop when easily done. The problem is that this ...
8
votes
4answers
644 views

What is the meaning of “inversion” in Dependency Inversion design principle?

I'm reading about design patterns. I know what this principle does. High-level and low-level classes depend on abstractions. But why we say this is inversion?
2
votes
1answer
320 views

How does dependency inversion principle work in languages without interfaces?

In C#/Java, the dependency inversion principle is often demonstrated by high-level classes that depends on an interface/abstraction (that it owns). Low-level classes will implement the interface, thus ...
3
votes
2answers
263 views

Single responsibility vs procedural programming

Single responsibility (from SOLID) is like making me create classes with only one public method. But if it's so, it would be possible use static methods, and go back to procedural programming. What's ...
1
vote
1answer
632 views

Liskov principle: violation by type-hinting

According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like ...