srp

Psuedo-Backwards Builder Pattern?

In a legacy codebase I have a very large class with far too many fields/responsibilities. Imagine this is a Pizza object. It has highly granular fields like: hasPepperoni hasSausage hasBellPeppers I know that when these three fields are true, we have a Supreme pizza. However, this class is not open for extension or change, so I can'...

Should my validator have access to my entire model?

As the title states I'm wondering if it's a good idea for my validation class to have access to all properties from my model. Ideally, I would like to do that because some fields require 10+ other fields to verify whether it is valid or not. I could but would rather not have functions with 10+ parameters. Or would that make the model and...

SRP & "axis of change"?

I'm reading Bob Martin's principles of OOD, specifically the SRP text, and I understand the spirit of what it's saying pretty well, but I don't quite understand a particular phrasing, from page 2 of the link (page 150 of the book): I paraphrase: It is important to separate these two responsibilities into separate classes because each r...

Single Responsibility and Mixins

Given that Mixins generally introduce new behaviour into a class, this generally implies that a class would have more than one behaviour. If a class has a single responsibility this is defined as the class having only one reason for change. So, I can see this from two different perspectives The class only has one reason for change....

Keeping code at the same level when dealing with static methods.

Hi all. This might be a little subjective, but I'd like to get your input on my current situation. I have a class that will be used to serialize/deserialize an object. public class MyClass { public static string ToXmlString( MyClass c ) { /*...*/ } public static MyClass FromXmlString( string xml ) { /*...*/ } } I only like th...

Separation of Concerns when adding new types

I have a system I've been working on this week where I'm having a hard time balancing separation of concerns with easy extensibility. I'm adding new types to the system, and it feels like shotgun surgery. The basic idea is that data is collected (polled) from a remote system and then made available to a number of different kinds of cli...

Single Responsibility Principle - A hard to see example?

I've just read about the Single Responsibility Principle and at one point Robert C. Martin states that it is sometimes hard to see that a class has more than one responsibility. Can anyone provide an example of such a class? ...

ASP.NET MVC Show to end user that action was successful

Most of the ASP.NET MVC examples I have seen depict scenarios where a user is viewing an object (or collection of objects) and then moves from that page to one that displays a form that the user completes. Upon submitting the form with good input, the user is redirected back to the page that shows the object (or list) and the user can s...