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

learn more… | top users | synonyms

0
votes
1answer
113 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
510 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
276 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
429 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. ...
21
votes
6answers
3k 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
767 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
296 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 ...
5
votes
1answer
626 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
338 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
625 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 ...
72
votes
7answers
5k 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
479 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
452 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
573 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
15k 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 ...
17
votes
5answers
5k 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
638 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
1k 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
214 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
978 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
649 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
330 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
509 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
480 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
292 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
277 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 ...
17
votes
3answers
1k 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
992 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 ...
8
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 ...
19
votes
12answers
1k views

SOLID vs. Avoiding Premature Abstraction

I understand what SOLID is supposed to accomplish and use it regularly in situations where modularity is important and its goals are clearly useful. However, two things prevent me from applying it ...
6
votes
2answers
737 views

What does “abstractions should not depend on details” actually mean?

Most readers will be familiar with Bob Martin's famous dependency inversion principle, which states - High-level modules should not depend on low-level modules. Both should depend on abstractions ...
0
votes
2answers
295 views

Trying to understand Single Responsiblity Principle [closed]

I'm having a difficult time understanding the Single Responsibility Principle. What should I look for to evaluate the various sources of information on the matter? What should I look for in ...
18
votes
4answers
2k views

Solid principles vs YAGNI

When do the SOLID principles become YAGNI? As programmers we make trade-offs all the time, between complexity, maintainability, time to build and so forth. Amongst others, two of the smartest ...
3
votes
4answers
474 views

Which one of the SOLID principles had the largest effect on your code? [closed]

Which if the SOLID principles introduced by "Uncle Bob" Martin had the largest effect on your day to day coding? Please give details!