Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single DLL V multiple DLLs

I asked a question on here some time ago when I wandered if it was better to split a large project (.NET class library) into multiple .NET DLLs. The advice was to have one large DLL.

This DLL is now used in another project. The other project only uses a few classes and therefore there are lots of classes in the project that are unused.

Is this bad practice from an architectural perspective to have one DLL or am I over thinking this?

like image 981
w0051977 Avatar asked Dec 01 '25 14:12

w0051977


1 Answers

There are certain pros and cons for having the seperate dlls:-

Cons:-

The performance and complexity may increase.

Pros:-

code reuse and layers organization

You may also be interested to check articles on good design (The starting five is about SOLID principles. The rest is about how to structure your dll's)

EDIT:-

You will be intersted to read this MSDN:-

Prefer Single Large Assemblies Rather Than Multiple Smaller Assemblies

To help reduce your application's working set, you should prefer single larger assemblies rather than multiple smaller assemblies. If you have several assemblies that are always loaded together, you should combine them and create a single assembly.

The overhead associated with having multiple smaller assemblies can be attributed to the following:

•The cost of loading metadata for smaller assemblies.

•Touching various memory pages in pre-compiled images in the CLR in order to load the assembly (if it is precompiled with Ngen.exe).

•JIT compile time.

•Security checks. Because you pay for only the memory pages your program accesses, larger assemblies provide the Native Image Generator utility (Ngen.exe) with a greater chance to optimize the native image it produces. Better layout of the image means that necessary data can be laid out more densely, which in turn means fewer overall pages are needed to do the job compared to the same code laid out in multiple assemblies.

Sometimes you cannot avoid splitting assemblies; for example, for versioning and deployment reasons. If you need to ship types separately, you may need separate assemblies.

NOTE:-

.Net DLL's are assemblies but the reverse is not true.

like image 103
Rahul Tripathi Avatar answered Dec 03 '25 06:12

Rahul Tripathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!