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

learn more… | top users | synonyms

2
votes
1answer
185 views

Open / Closed Principle

I found this code example explaining Open / Closed principle. Code before application of principle: public class Logger { public void Log(string message, LogType logType) { switch ...
2
votes
3answers
123 views

Dependency Inversion Principle - No deriving from concrete classes?

I'm not sure if I am getting this right. In order to observe proper SOLID principles, am I forbidden to inherit from concrete classes? Does that mean that every concrete class that I have more or less ...
1
vote
1answer
33 views

Does having a EntityBase or DomainBase class violate LSP?

Suppose we have a abstract class EntityBase which is the base class for all our entities e.g. public abstract class EntityBase { public Guid Id {get;set;} } public class Customer : EntityBase { ...
9
votes
2answers
437 views

Interface Segregation Principle: What to do if interfaces have significant overlap?

From Agile Software Development, Principles, Patterns, and Practices: Pearson New International Edition: Sometimes, the methods invoked by different groups of clients will overlap. If the overlap ...
-1
votes
1answer
41 views

SRP. Save to repository when edit. Internally or externally? [closed]

For example: class Data { private String field1; private String field2; public void someEditMethod() {} } class DataRepository { public void save(Data data) { // save to DB ...
20
votes
5answers
1k views

Do special-cases with fallbacks violate the Liskov Substitution Principle?

Let's say I have an interface FooInterface that has the following signature: interface FooInterface { public function doSomething(SomethingInterface something); } And a concrete class ...
5
votes
1answer
90 views

Choosing between Dependency Inversion and Dependency “Delegation” to a third module

Suppose I have MasterPackage containing a Master class, and BlasterPackage containing Blaster class. Since Master needs a Blaster to work, the higher level MasterPackage depends directly on ...
3
votes
2answers
138 views

Design review of a small configuration framework [closed]

I want to create a simple configuration framework. Yes I know, there are many frameworks, which make their job very well. But for interesting in architecture, I want to create my own. My framework ...
5
votes
1answer
177 views

What evidence is there that obeying the Open/Closed principle reduces bugs?

I'm currently putting together a talk where I discuss the value of unit tests in enforcing the SOLID Open/Closed principle. However beyond the obvious "the bug wasn't there when I wrote it, it's been ...
0
votes
1answer
70 views

Does extending a ruby class violate the LSP?

I am reading about SOLID principles. In Ruby tutorials and code samples, I often see subclass extensions like: class House attr_reader :items end class Room < House attr_reader :chair end p ...
0
votes
0answers
66 views

Did Apple violate OCP back when they released iOS 7

If I remember correctly, back when iOS 7 was released, there were a couple of issues regarding the public API of certain classes which implementation was completely changed. The following is an ...
2
votes
3answers
302 views

Is this avoiding inheritance correctly?

I want to add capabilities for an abstract Model class to send events whenever it updates. To be able to send events, it needs to have access to an EventManager. So, the intent were first, to be able ...
1
vote
1answer
94 views

Stuck on design when attempting to create an object store

I'm working on a small scale API project but as it will be used and maintained by people that are not Software Engineers to trade I am attempting to keep the design as separate and identifiable as ...
2
votes
2answers
350 views

Does class inheritance (in C#) violate the Open/Closed Principle?

I typically make all my methods private unless and until they need to be overriden by a sub-class. At that point I modify the base class to make that particular method protected virtual. Is it ...
2
votes
1answer
99 views

Does implicit and explicit cast operator overloading violate the D in SOLID principles of OO?

I'm looking at different patterns and techniques for implementing logic to convert object from one class to another, and the most elegant seems to be explicit cast operator overloading (in C#). ...
2
votes
2answers
184 views

Justifying programmatically ensuring frontend and backend validations are synchronised

Like many Javascript-based rich web apps these days, I have some complicated validation rules implemented on the front-end. The same rules are supposedly repeated exactly on the Java backend but I ...
3
votes
5answers
128 views

Can encapsulation be implemented by proper types rather than accessors?

Interesting question came up while designing interfaces at work, now resolved, but I want to ask about the theory behind it. Is it incorrect to say that properly typed data members of a class provide ...
3
votes
1answer
105 views

How does this example from Robert Martin's book violate the Single Responsibility Principle? [duplicate]

According to the book "Clean Code" on page 38, the following lines of code violate the single responsibility principle. However, I cannot understand how there are "multiple" reasons for it to change? ...
2
votes
2answers
171 views

Maintaing drop down lists for the application

What would be the best approach to maintain the dropdown lists for the whole application (like city, state etc) taking into account the SOLID principles and performance? Right now am loading the list ...
13
votes
4answers
1k views

Do mocks violate the Open/Closed principle?

Some time ago I read, on a Stack Overflow answer that I can't find, a sentence that explained that you should test public APIs, and the author said that you should test interfaces. The author also ...
1
vote
1answer
231 views

C# Refactoring Code OOD and SOLID [closed]

I’m having some questions regarding improvement of code structure and maintainability, especially regarding SOLID. These questions are specifically for this project, so I would be happy if this ...
0
votes
2answers
204 views

Private setters and getters

I am learning OOP - I have read this answer a number of times and now slowly start to understand some of the practical uses of public interfaces (getters and setters). I understand there is no need to ...
1
vote
1answer
56 views

How do you keep up with 'requiring new methods in an interface' (Following LSP and adding new methods to interface seems to violate ISP)

I have a game that deals with opening and closing doors and the Door Engine deals with IDoor interface which has Open() and Close() contracts So far so good. the game is tested and works fine. Now a ...
4
votes
2answers
766 views

How to use SOLID principles in this example

I have reading about SOLID principles last week and decided to try to solve real world problem by using them. So I got the problem of real world ecommerce site managing totals. Problem Statement: ...
-2
votes
1answer
71 views

Programming to an Interface and Keep Testability in Unique Classes [duplicate]

I try to program to an interface whenever possible, but when I have a class that fulfills a very specific and unique purpose, one that can't be abstracted. Is it correct for me to say that I've ...
1
vote
3answers
90 views

Programming to an Interface and Interface Segregation in the Context of a User Class [duplicate]

I try to program to an interface whenever possible, but its not clear to me how I could apply it to a model as broad as a user. Which can hold many disparate fields (name, age, phone number, ssn, ...
5
votes
2answers
147 views

When applying the interface segregation, should you separate interfaces for regular setters and mathematical operations?

When applying the interface segregation, should you have separate interfaces for a straightforward setters and interfaces that perform an operation before setting? For example, say you have a class: ...
14
votes
5answers
1k views

Is the semantic contract of an interface (OOP) more informative than a function signature (FP)?

It is said by some that if you take SOLID principles to their extremes, you end up at functional programming. I agree with this article but I think that some semantics are lost in the transition from ...
1
vote
3answers
108 views

@Qualifier and Dependency Inversion Principle

I recently discovered SOLID principles and i'm trying to learn how to properly apply them. I have an application that had a huge interface: public interface NotificationService { public void ...
2
votes
3answers
117 views

Architecture: Should I schema validate incoming reply messages?

A web service I consume uses XSD to describe its API. Recently, they added a field to a reply message where no xsd:any had been, so when our schema validator tried to validate against the previous ...
0
votes
1answer
77 views

Provide part of context to class using interface

Currently I have class Context which I inject in some places in my code, like: protected override object GenerateSomething (object input, Context ctx) Depending on Context, Generate method gives ...
0
votes
0answers
416 views

Adding functionality to the activity (inheritance, decoration, strategy … ) or multiple inheritance

I cannot decide what approach should I use in the next situtation. One activity from my app need to have different functionality, here is the leak of multiple inheritence comes into play. ...
1
vote
3answers
143 views

Dependency inversion without static methods?

It's clear that the dependency inversion principle and the use of interfaces makes software components less coupled and promotes maintainability. On the other hand, these principles make using static ...
4
votes
2answers
156 views

Is it considered good practice to declare base interfaces without mutators, supplying mutatators in a sub-interface

I asked a question on StackOverflow on how to properly implement an ImmutableMap that abides by the SOLID principles. Due to Java's Map interface containing put and putAll, it violates the interface ...
3
votes
2answers
185 views

Is Dependency Inversion a valid alternative to the pImpl idiom?

If I want to present to the user of my code an interface, that is unlikely to change, I can write only the public part of the classes in public headers and have a single private pointer to another ...
31
votes
7answers
4k views

When NOT to apply Dependency Inversion?

I am currently trying to figure out SOLID. So Dependency inversion means that any two classes should communicate via interfaces, not directly. E.g. if class A has a method, that expects a pointer to ...
1
vote
1answer
204 views

Does merely parameterizing a dependency meet the requirements for Inversion of Control?

When I find a concrete dependency inside an extension method, I have been attempting to remove the (concrete) dependency by parameterising it like so // original implementation public static ...
2
votes
2answers
215 views

Is there a name for the problem of representing state twice and then getting out of sync? [closed]

I have a system that has configurable state values, like BoxCount, "Number of Visible Boxes on the screen". If I am using some heavyweight set of patterns (like MVC) that enforce the creation of ...
3
votes
2answers
585 views

How can I avoid tight coupling when practically every decision-logic has to check lots of distributed state?

As the senior developer in our company, I am currently starting to move our commercial php-mysql e-commerce solution (which takes data from a specific ERP-system) from procedural spaghetti-code which ...
0
votes
1answer
96 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
203 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 ...
4
votes
3answers
916 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 ...
1
vote
1answer
91 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
284 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 ...
3
votes
2answers
773 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 ...
2
votes
3answers
335 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 ...
0
votes
1answer
120 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 ...
2
votes
2answers
214 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 ...
5
votes
2answers
371 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 ...
42
votes
5answers
7k 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 ...