solid-principles

The Open/Closed Principle

The Open/Closed Principle states that software entities (classes, modules, etc.) should be open for extension, but closed for modification. What does this mean, and why is it an important principle of good object-oriented design? ...

How do you define a Single Responsibility?

I know about "class having a single reason to change". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility? Or could the real answer hide in YAGNI and only refactor to a single responsibility the first time your class changes? ...

Monkey-patching Vs. S.O.L.I.D. principles?

I'm slowly moving from PHP5 to Python on some personal projects, and I'm currently loving the experience. Before choosing to go down the Python route I looked at Ruby. What I did notice from the ruby community was that monkey-patching was both common and highly-regarded. I also came across a lot of horror stories regarding the trials of ...

How to separate data validation from my simple domain objects (POCOs)?

This question is language agnostic but I am a C# guy so I use the term POCO to mean an object that only preforms data storage, usually using getter and setter fields. I just reworked my Domain Model to be super-duper POCO and am left with a couple of concerns regarding how to ensure that the property values make sense witin the domain. ...

Patterns to implement SOLID principles

I'm doing a presentation of Solid design principles and I'm trying to connect the single responsibility principle and the open and closed principle to design patterns. Currently I have, SRP- proxy, fascade OCP- strategy, command Are there any other basic patterns I should include? ...

Data Transfer Object Pattern??

Hi Guys I've got a problem where I need to generate a Word based reports on object “Customer”. I usually do this by passing Customer to a class which knows how to create a Word document, insert bookmarks etc. The problem with this, is that I find myself placing the logic for retrieving and formatting information about the Customer obj...

Do you put Linq2SQL queries all over the place or in dedicated DAL classes?

I have always inserted my Linq2SQL queries all over the place, in almost every class all over the place. I woud like to know what your strategy about where to put your Linq2SQL queries? Do you put them in separate datalayer classes or do you store them where they are used all over the place? I think that I need to chang my strategy f...

SOLID and the user interface ?

I try to follow the SOLID principles. But every time it comes to user interfaces I find that there's an inherent friction between the clunky screenful of hybrid, aggregated data the customer requires and the nice principles of single-responsibility. Now it is possible to divide and conquer the various bits and pieces of a typical user i...

Examples of great software design and implementation

I hope this isn't a duplicate... What is the most solidly designed and implemented software system/framework/application that you've come across? It seems like TDD, SOLID principles, OO design patterns, and things like that can be easily theorized on podcasts and blogs using really simple examples, but it's hard to imagine developing ...

Open source projects that demonstrate TDD and SOLID priciples

I asked a similar question before, and got some good answers, but I think it was too general. http://stackoverflow.com/questions/559484/examples-of-great-software-design-and-implementation Does anyone know of any open-source projects that demonstrate really good TDD practices, and SOLID principles? TDD and SOLID are widely publicized,...

What are the OSS .net/java projects which has utilised most SOLID Principles in a rightway?

I would like to see/learn how solid principles are utilized in a right way in a real projects. Or there is none? ...

How to build the ViewModel in MVVM not to violate the Single Responsibility Principle?

Robert Martin says: "There should never be more than one reason for a class to change". Let's consider the ViewModel class which is bound to a View. It is possible (or even probable) that the ViewModel consists of properties that are not really related to each other. For small views the ViewModel may be quite coherent, but while the appl...

Anything wrong with this kind/type of coding style?

Is there anything wrong with the below code? It is java codes, but somehow it looked like a C program to me. If there is something incorrect with the OO implementation, can you tell me the name of the violation? looking at S.O.L.I.D or CodeSmell but I still have no idea why the below codes looked weird to me. public void root() { B...

It this an example of the Single Responsibility Principle?

I made the following code example to learn how to use a generics method signature. In order to get a Display() method for both Customer and Employee, I actually began replacing my IPerson interface with an Person abstract class. But then I stopped, remembering a podcast in which Uncle Bob was telling Scott Hanselman about the Single R...

How to implement SOLID principals into an existing project

I apologize for the subjectiveness of this question, but I am a little stuck and I would appreciate some guidance and advice from anyone who's had to deal with this issue before: I have (what's become) a very large RESTful API project written in C# 2.0 and some of my classes have become monstrous. My main API class is an example of thi...

How does this "Programming to Interfaces" thing work?

I like the idea of "programming to interfaces" and avoiding the use of the "new" keyword. However, what do I do when I have two classes that have the same interface but are fundamentally different to set up. Without going into detail about my specific code, I have an interface with a method, "DoStuff". Two classes implement this interfa...

Confused about Single Responsibility Principle in the following example

In the following video, the author takes an existing class and assigns the Single Responsibility Principle to it. He takes a Print Class that has the job of Accessing Data, Formatting, and Printing the report. He breaks up each method to its own class, so he creates a DataAccess class to handle data access, he creates a ReportFormatter...

Cancel pattern for background thread

I have code running in a background thread that need to periodically check if the user wants to abort the work. The question is how to implement this in a mostly SOLID environment. An ICancel interface that I inject into every class. A public static member somewhere Non-const statics seem to always create problems sooner or later. O...

What is your best example of a violation of the Single Responsibility Principle?

I'm looking for some good examples of code that violates the Single Responsibility Principle. Don't show me any examples from Uncle Bob's books or web sites since those are plastered all over the internet, like this one: interface Modem { public void dial(String pno); public void hangup(); public void send(char c); publ...

Single Responsibility Principle vs Anemic Domain Model anti-pattern

I'm in a project that takes the Single Responsibility Principle pretty seriously. We have a lot of small classes and things are quite simple. However, we have an anemic domain model - there is no behaviour in any of our model classes, they are just property bags. This isn't a complaint about our design - it actually seems to work quite w...