I’m trying to refactor some “sending out an email” code by dividing the steps (validate, attach related content, format, send) into separate classes that can be more easily tested, logged, and updated.
As part of this I’ve got to figure out a way for the operations to communicate validation or transient errors (“that item was deleted”)...
What is the difference between Single Responsibility Principle and Separation of Concerns?
...
I’ve been professionally writing VB.NET software for seven years. However, I don’t have a strong computer science background – four courses while studying education at university in the 90s that gave me some CS basics and exposure to Pascal, C and Lisp. Anyway, there are a whole bunch of practices that I’m missing – testing, patterns, ...
I have a problem with deciding about class responsibilities.
I have 3 html-forms:
For each form there is a html template containing some text and a marker for the form to be included
Each form needs to be validated, if there is an error the template and the form from (1) needs to redisplayed, together with some error messages. Only som...
This is more of a theoretical question. Should logging reside within a class who's primary purpose is not logging?
Here is a simple interface for anything that will preform a calculation on a number.
public interface ICalculation {
public int calculate(int number);
}
Here is an implementation of the ICalculation interface that...
I'm getting push back on a design from a colleague, and am wondering if there's consensus as to who is correct on application of SRP in this case.
I see SRP as relating mostly to the lower-level details of design, such as class responsibility. As you move up in levels of abstraction I believe SRP is still relevant but that the definiti...
In the system I'm currently working on, I'm following SRP (I think!) by separating the validation of domain business rules vs persistence constraints. Let's employ the overused customer example. Say a customer must have a valid zip code, street address and name to satisfy the system's business rules. Let's further say that the customer...
I've got this question about form validation and business validation.
I see a lot of frameworks that use some sort of form validation library. You submit some values and the library validates the values from the form. If not ok it will show some errors on you screen. If all goes to plan the values will be set into domain objects. Here th...
i have a data access layer that abstracts the rest of the application away from the persistence technology. Right now the implementation is SQL server but that might change. Anyway, i find this main data access class getting larger and large as my tables grow (about 40 tables now). The interface of this data access layer is any questi...
I'm refactoring some code I wrote a few months ago and now I find myself creating a lot of smallish classes (few properties, 2-4 methods, 1-2 events).
Is this how it's supposed to be? Or is this also a bit of a code smell?
I mean if a class does need a lot of methods to carry out it's responsibility, I guess that's how it's gotta be,...
A fellow developer and I are conversing (to put it lightly) over Lazy-Loading of Properties of an object.
He says to use a static IoC lookup call for resolution and Lazy-Loading of objects of an object.
I say that violates SRP, and to use the owning Service to resolve that object.
So, how would you handle Lazy-Loading following I...
I'm trying to adhere to Single Responsibility Principle better, and I'm having issues grasping how to structure the general class design for communicating with a database. In a simplified version, I essentially have a database containing:
Manufacturer <== Probes <==> ProbeSettings
A probe has a manufacturer. A probe has 1 set of se...
I'm trying to understand what a responsibility actually is so I want to use an example of something I'm currently working on. I have a app that imports product information from one system to another system. The user of the apps gets to choose various settings for which product fields in one system that want to use in the other system.
S...
For my purposes, I need to search for a specific node in an xml file and, if found, delete it. Should I pull search functionality out into its own method and delete functionality out into its own method? It seems more expensive to do it this way because I'll be searching the xml file once to see if it exists and searching it again to d...
In the SRP, a 'responsibility' is usually described as 'a reason to change', so that each class (or object?) should have only one reason someone should have to go in there and change it.
But if you take this to the extreme fine-grain you could say that an object adding two numbers together is a responsibility and a possible reason to ...
I have a functional AdjacencyListGraph class that adheres to a defined interface GraphStructure. In order to layer limitations on this (eg. acyclic, non-null, unique vertex data etc.), I can see two possible routes, each making use of the GraphStructure interface:
Create a single class ("ControlledGraph") that has a set of bitflags spe...
hi ,
i have download srp-2.1.2 package and just try to compile it under ubuntu.
but it is not going to be compiled completely.
please tell me how to compile it under ubuntu .
error-
root@ubuntu:~/Desktop/srp-2.1.2/libsrp# make
gcc -DHAVE_CONFIG_H -I. -I. -I. -fPIC -O -c t_client.c
gcc -DHAVE_CONFIG_H -I. -I. -I. -fPIC -O -c t_...
hi ,i have compiled srp-2.1.2 under ubuntu using make ,it creat a file libsrp.a. can any one tell me how can i use libsrp.a as shared library?.i want to use libsrp in a c# file under ubuntu by using dllimport.please tell me what is the meaning of libsrp.a file.
thanks
ok when i am using nm -D libsrp.a
then i have
c2@ubuntu:~/Desktop...
Hello
Suppose we are designing a UserServiceImpl class which does CRUD(Create, Read, Update, and
Delete) operations. In my view Create, Read, Update, and Delete are four reasons for a
class to change. Does this class violates Single Responsibility Principle? If it violates,
then should we have four classes like CreateUserServiceIm...
Wikipedia describes the Single Responsibility Principle this way:
The Single Responsibility Principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.
The traditional use of the co...