views:

29

answers:

2

I've been working on a Composite WPF application and just read some good guidelines on partitioning code into assemblies. The author of the article supports minimizing the number of assemblies where possible.

How do you balance making your Composite WPF application reasonably modular while minimizing the number of assemblies?

For my current project I started off by creating a module for each logical group of functionality, which lead to quite a few (14) smallish assemblies. If I were to refactor this and try to minimize assemblies, I could get it down to 6 while still in keeping with the Composite WPF architecture, but I wonder if I am losing some flexibility... maybe I should remember YAGNI.

A: 

Go ahead and divide your code in as much assemblies as you need to keep it easy to understand and to maintain. Later if you discover performance problems in your application, and these are due to an excessive number of assemblies, you can start thinking on joining some of them. Just make sure to have a clear object model design and namespace structure so that you don't lose track of your code regardless of how many assemblies you are using.

Konamiman
+1  A: 

Besides YAGNI, remember also the Separation of concerns and the Lazy loading patterns and use them to your benefit. There is no use in having fewer assemblies that bundle a lot more potentially unneeded functionality that belongs to different aspects of your application. Also keep in mind that it's also a lot easier to maintain code that keeps a low coupling, as you may risk inducing bugs by bundling in the same assembly functionality that does not belong together.

You may want to do some usability tests in typical use-scenarios of your application, and see what modules are frequently needed together, rely on each other, or inherit from one another and bundle these in the same assemblies. The modules that have disjoint functionality - making a choice leads to loading one OR another, but never both, should especially be kept in separate assemblies.

luvieere