N-Layered ASP.NET Application: One class library for all my layers or one class library for each layer?

735 views Asked by At

N-Layered ASP.NET Application: One class library for all my layers or one class library for each layer?

5

There are 5 answers

1
Jeffrey L Whitledge On BEST ANSWER

If your project is small enough that only one library suffices for each layer, then I would go with that approach. This helps to maintain a clear separation of concerns.

Separate DLLs will not adversly affect performance in my experience. There are some situations where it can assist performance (such as delay-loading rarely-used components). All the DLLs are loaded into the same address space, so as far as the runtime is concerned, one or many DLLs makes hardly any difference.

Each layer should be authored as though multiple front-ends are going to be using it. This will further help to maintain separation, and encourage code that is more correct and easier to maintain.

4
Darius Kucinskas On

I would go for class library for each layer. This way you could reuse you libraries in other projects. Also this will give you more flexibility...

2
Kris Ivanov On

why not use both, one common class library for all global stuff and one class library for each of the projects for project specific things

of course we need to know more about your particular situation to be more accurate, there is no one-case-fits all solution unfortunately

2
Ahmet Altun On

I prefer one class library for each layer. It provides good organization and hierachy between libraries. For example, UI layer never knows about Data Access Layer and it cannot know since it doesn't have reference to Data Access Layer.

However, sometimes layers are placed in the same class library to shorten the compilation time. If you don't have an overhead like this, always choose seperated one.