views:

25

answers:

1

Let's say I have a Visual Studio solution with a Web project, a BLL project, and a DAL project. I'm trying to follow the repository pattern keeping my SQL code in the DAL with an interface that is referenced by the BLL.

I have a handful of common solutions for things such as error handling, usage logging, and other things that can be considered utility functions (i.e. not in the business spec). I'm keeping these in a Common project.

Here are a few ideas I've had with regards to structuring the Common project...

  1. Bundle SQL with logic in a given class
  2. Create a layered solution within the Common project
  3. Discard the Common project and put utility functions in with BLL/DAL

Is one of these ideas better/worse than the other? Does anyone have a better solution?

It's worth noting that these utility functions will be reused in a variety of other applications.

A: 

Instead of creating a Utilities project which will be used have you thought about creating something that can provide a service? You might want to look at Aspect Oriented Programming. Red flags went up when I saw you listing off your examples error handling, logging, etc. Those scream AOP.

But if you want to stick with your layout.

I think I would go with 2, assuming that means restructuring the utilities project to be more Cohesive.

I don't understand (please clarify and I will edit my post)

  1. Bundle SQL with logic in a given class

As for:

Discard the Common project and put utility functions in with BLL/DAL

I would be against doing so. If this logic is truly going to be repeated there is no need to push it back into your projects. This will lead to duplicate code and increased maintenance.

Side Note:

Just as a lessons learned, the only way Utilities projects work, are if you are the only developer or it is well documented and well designed. Sometimes utilities are too programmer specific, or are written in a way that only benefits a particular coders style. I have seen countless times people rework their infrastructure pulling out all kinds of utilities, only to see their utilities project never get used. Make sure the "utilities" you are creating are truly useful to other people.

Nix