tags:

views:

111

answers:

2

Where should resource files go and at what granularity (application/assembly/namespace/class/...)?

Using a layered architecture one can split an applications into separate dedicated assemblies. An advantage is that it is easier to manage dependencies and ensure that code does not get entwined.

During application wide refactoring, pieces can be split out into separate assemblies or moved into their own assembly. This could happen because the functionality had matured enough to be moved into the core layer or has become large enough to warrant moving it into its own assembly.

During the refactoring process resource might have to be moved. It might be more or less difficult depending on the strategy used for grouping resources and the type of refactoring being done. Resources (strings, images, files, etc...) could have been grouped in quite a few ways: - in a single resource file per assembly, - in a resource file per namespace within an assembly, - in a resource file for each class, - in a single assembly shared by all assemblies within the application, - etc.

Refactoring is just one operation which could be affected by the chosen grouping strategy for resources. Other operations, like translation of the strings in the resource files will also be influenced.

What grouping strategy is considered best and why?

+1  A: 

Just making more of a comment than an answer here, but you should have a look at this: MSDN Internationalization page.

Whatever decisions you make regarding resources should keep in mind how your structure will work with internationalization, if you have to go international then you will have big problems if your structure constricts you.

Spence
A: 

I usually tie resources to an assembly, but if you're not sure what the future will bring then a shared resources dll might be a good solution for you.

Gerrie Schenck
I don't like the idea of a shared resource assembly. You might end up with a system suffering from low cohesion. If I were to only share a single assembly with another application the I'd have to ship all the other resources. I'm prone to favour keeping things closer. That way it is more manageable in the future.
Christo