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

learn more… | top users | synonyms

2
votes
2answers
547 views

Is it a Single Responsibility Principle violation?

I'm designing an OO graph library and at the moment I'm trying to figure out the design for a GraphEdge class. I've added setters and getters for it's nodes, direction and weight. This seemes ...
2
votes
2answers
2k views

Programming against a protocol in Objective-C

I stumbled accross the SOLID principles. There is one burning question. Should I always use protocols? I never saw someone using them in the way that a Java developer would use them. I tried it in a ...
2
votes
1answer
217 views

Creating an interface of interfaces

Background: We have a class that both listens on a socket and sets values on itself based on what it reads off the socket. I believe that adheres to SRP. To adhere to ISP we created one interface ...
6
votes
2answers
474 views

Is it good to have an interface plenty of methods which belong to different concepts, just to preserve the Liskov's Principle?

I'm currently studying a course based on Software Design and I had a discussion in class with my professor and some classmates about a problem represented by the next scenario: Scenario Imagine ...
3
votes
2answers
305 views

Single Responsibility principle VS KISS principle

Let's assume the modeling of User model in a context of a social network. User concept is composed of two notions: Authentication elements like userName/Password/Email etc... Extra data information ...
4
votes
1answer
528 views

Xerox SOLID example in PHP

There is a good example on Wikipedia regarding the violation of SOLID principles. The ISP was first used and formulated by Robert C. Martin while consulting for Xerox. Xerox had created a new ...
3
votes
2answers
174 views

Are there any well-known quantitative approaches to evaluate a particular design whether it satisfies or violates the SOLID design principles? [duplicate]

I designed an application framework by considering the SOLID design principles and supported by design patterns. However, I wonder if there are any automated tools or well-known approaches to evaluate ...
4
votes
3answers
582 views

Do setters and getters always break the Single-Responsibility Principle?

As we know, The SRP states that every class should have single responsibility and that responsibility must be entirely encapsulated by the class. But setters and getters do serve another ...
3
votes
3answers
456 views

Simple questions to test understanding of Dependency Inversion Principle

I am preparing a short (1-2 hour) presentation about DIP to several (~5) junior developers (1-3 yr xp) in the office. At the end of the presentation I want to know whether they understood what I was ...
10
votes
3answers
773 views

Dependency Inversion Principle: How to define “high-level policy” and “low-level detail” to other people?

I am trying to explain the dependency inversion principle to my (mostly junior) colleagues. How can we define which one is the "high-level policy" and which one is the "low-level detail" in a ...
2
votes
1answer
318 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 ...
1
vote
3answers
259 views

Should methods always be closed for modification?

Say I have a method called 'functionA' that is called by a service and carries out a single piece of functionality, it is easy to unit test as it is does one thing only. If a few months later an new ...
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?
0
votes
1answer
118 views

What are the reasons for rebuild and redeployment libraries?

It's difficult to understand the meaning of the question from the topic's name. Here is what I mean. I'm watching Uncle Bob's Clean Code Episodes. In many episodes where he is talking about SOLID ...
10
votes
6answers
516 views

Do changes in performance violate the Liskov Substitution Principle?

Say I have: interface Thing { GetThing(); } class FastThing : Thing { public int GetThing() { return 1; } } class SlowThing : Thing { public int GetThing() { ...
3
votes
2answers
294 views

Can I apply SOLID concepts to entire solution designs rather than just the internal components?

So maybe the quick answer is 'Yes' absolutely (or no I suppose), but let me explain my question angle to get a better derived answer. We all commonly use SOLID design principals when making up the ...
2
votes
1answer
489 views

Liskov substitution and abstract classes / strategy pattern

I'm trying to follow LSP in practical programming. And I wonder if different constructors of subclasses violate it. It would be great to hear an explanation instead of just yes/no. Thanks much! P.S. ...
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 ...
5
votes
3answers
806 views

Tension between the dependency inversion principle and avoiding “new” in C++?

I have seen a lot of advice that it is better to do Type object; than Type* object = new Type(); in C++ whenever possible—i.e., minimize your use of new. I understand the rational behind this and ...
0
votes
2answers
305 views

Examples of Liskov Substitution [closed]

I'm facilitating a session next week on the Liskov Substitution Principle and I was wondering if anyone had any examples of violations 'from the trenches'? I'm looking for something other than uncle ...
6
votes
1answer
782 views

Is wrapping a third party code the only solution to unit test its consumers?

I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework. Now ...
4
votes
4answers
349 views

Are injectable classes allowed to have constructor parameters in DI?

Given the following code: class ClientClass{ public function print(){ //some code to calculate $inputString $parser= new Parser($inputString); $result= ...
18
votes
8answers
2k views

What can go wrong if the Liskov substitution principle is violated?

I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what ...
11
votes
1answer
686 views

How to verify the Liskov substitution principle in an inheritance hierarchy?

Inspired by this answer: Liskov Substitution Principle requires that Preconditions cannot be strengthened in a subtype. Postconditions cannot be weakened in a subtype. Invariants ...
73
votes
7answers
6k views

Is this a violation of the Liskov Substitution Principle?

Say we have a list of Task entities, and a ProjectTask sub type. Tasks can be closed at any time, except ProjectTasks which cannot be closed once they have a status of Started. The UI should ensure ...
15
votes
2answers
1k 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?
4
votes
5answers
494 views

Should concrete classes avoid calling other concrete classes, except for data objects?

In Appendix A to The Art of Unit Testing, Roy Osherove, speaking about ways to write testable code from the start, says, An abstract class shouldn't call concrete classes, and concerete classes ...
9
votes
2answers
466 views

Is there an “ask for only what you need” interface principle?

I have grown into using a principle for designing and consuming interfaces that says basically, "ask for only what you need." For instance, if I have a bunch of types that can be deleted, I'll make ...
3
votes
5answers
605 views

Is my mediator layer a sensible way to manage this scenario using the Single Responsibility Principle?

I'm not sure how to start to explain my question, but here goes. We have just finished an MVC application that hits 2 WCF services. But there has been a bit of a disagreement between those who worked ...
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 ...
19
votes
5answers
6k views

What are the design principles that promote testable code? (designing testable code vs driving design through tests)

Most of the projects that I work on consider development and unit testing in isolation which makes writing unit tests at a later instance a nightmare. My objective is to keep testing in mind during ...
11
votes
5answers
672 views

Is overloading an example of the Open/closed principle?

Wikipedia says "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" The word functions caught my eyes, and I now wonder if we can ...
12
votes
4answers
2k views

Where should you put constants and why?

In our mostly large applications, we usually have a only few locations for constants: One class for GUI and internal contstants (Tab Page titles, Group Box titles, calculation factors, enumerations) ...
2
votes
2answers
228 views

Does SRP with ORM provoke SOA?

Sorry about the many abbreviations in the title... My observation is that applications built with an object-relational mapping like Hibernate tend to follow a service-oriented architecture instead of ...
10
votes
9answers
2k views

SOLID vs. static methods

Here's a problem I frequently run into: Let there be a web shop project that has a Product class. I want to add a feature which allows users to post reviews to a product. So I have a Review class ...
21
votes
11answers
991 views

Choose code design effort or laziness in Bank world

I've worked for two years in a great Investment Bank. I made some technical projects with the desire of creating code the most optimized, respecting the adapted good design patterns, SOLID principle, ...
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 ...
4
votes
6answers
346 views

Does calling a virtual protected method from a base class violate the LSP?

Let's say we have this base class: class MyBase { public string Name { get; set; } public string GetDescription() { var descriptionList = new List<string>() { this.Name }; ...
4
votes
3answers
539 views

Single Responsibility Principle Implementation

In my spare time, I've been designing a CMS in order to learn more about actual software design and architecture, etc. Going through the SOLID principles, I already notice that ideas like "MVC", ...
22
votes
10answers
3k views

How many are too many interfaces on a class?

I would probably consider it a code smell or even an anti-pattern to have a class that implements 23 interfaces. If it is indeed an anti-pattern, what would you call it? Or is it simply just not ...
9
votes
3answers
490 views

Is discoverability for developers a problem when using SOLID principles?

I do line of business apps where the all the other developers are used to doing basic CRUD apps or are focused solely on making pretty/functional interfaces and I am getting the following a lot. ...
8
votes
2answers
315 views

When following SRP, how should I deal with validating and saving entities?

I've been reading Clean Code and various online articles about SOLID lately, and the more I read about it, the more I feel like I don't know anything. Let's say I'm building a web application using ...
3
votes
1answer
287 views

Do “Builder” static methods violate SOLID?

I am writing a class which consists mostly of data storage responsibilities. The context for the use of this class will, in general, be retrieving an array of objects of this type for display later. ...
11
votes
4answers
1k views

Does test-driven development force me to follow SOLID?

I hear a lot from TDD practitioners that one of TDD's advantages is that it forces developers to follow SOLID principles (Single responsibility, Open-closed, Liskov substitution, Interface segregation ...
5
votes
3answers
1k views

What should I name this helper class? [closed]

Usually when writing unit tests I create a helper class with extension methods. I use these methods exclusively for generating generic data for things that I am too lazy to type out. I usually name ...
10
votes
3answers
1k views

Applying SOLID principles

I am quite new to the S.O.L.I.D. design principles. I understand their cause and benefits, but yet i fail to apply them to a smaller project which I want to refactor as a practical exercise to use the ...
19
votes
3answers
2k views

How is dependency inversion related to higher order functions?

Today I've just seen this article which described the relevance of SOLID principle in F# development- F# and Design principles – SOLID And while addressing the last one - "Dependency inversion ...
25
votes
3answers
1k views

Are static classes with static methods considered SOLID?

SOLID includes the Liskov substitution princicple which has the notion that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that ...
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 ...
9
votes
4answers
1k views

How does thinking on design patterns and OOP practices change in dynamic and weakly-typed languages?

There is a fairly helpful question already along these lines ("Non-OOP Design Patterns?"), but I am more curious about a transitional point of view for someone just getting started with dynamic and ...