4

Is it better to have multiple DLLs or a single large DLL? Or does it matter?

The application I'm working on is large with many namespaces. Currently, each namespace is contained within a separate DLL, however we've been thinking about combining several of them to simplify dependency issues.

When a namespace is referenced, will all the other namespaces be loaded into memory as well? I'm just concerned about performance.

ks78
  • 927
  • 2
  • 17
  • 34

1 Answers1

4

Namespaces and assemblies (DLLs) both provide ways to partition your project, but they do it in different ways: namespaces provide logical partitioning, while assemblies provide physical partitioning.

Very often the boundaries of these partitioning match exactly, but it does not need to be so: you can have classes from the same namespace appear in multiple assemblies; you could also put classes from multiple namespaces into the same assembly.

A rule of thumb for creating a new assembly that I follow is simple: if there is a situation when one group of classes can be used independently of another group of classes, the two groups should go to separate assemblies. This gives you more flexibility in mixing your assemblies as dependencies of other projects. Since dependencies of your dependencies are loaded lazily, making smaller DLLs lets you better manage the runtime footprint of your application.

The biggest issue associated with multiple DLLs is a significant increase of compile time. Fortunately, it can be addressed by managing the "Copy Local" setting.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523