views:

143

answers:

5

I have this:

SolutionName: Foo.sln

Assembly: Foo.Bar

Namespaces are:

Foo.Bar.Views
Foo.Bar.Model
Foo.Bar.BusinessObjects
Foo.Bar.Services

Should the directory structure be like this?

__Foo/Foo.Bar/Foo.Bar.View__ or __Foo/Bar/View__
A: 

Well, it can be anything you wish. Either are valid, but the former might get a little redundant and lead to directory hierarchies which are a little hard on the eyes/prohibitive.

casperOne
+1  A: 

If you keep the Visual Studio option of "Automatic Namespaces" you would need to have Foo/Bar/Views. Since this is the default behavior of Visual Studio people will be most used to this. Plus it keeps your folder names/paths from getting excessively long.

Agent_9191
If memory serves, that's only true for C#. Visual Basic doesn't enforce this mapping between namespaces and directories.
Mike Hofer
A: 

Foo/Bar/View seems to be natural. Also MSVS tends to map solution folders to namespaces (i.e. if you add Abc folder to your solution each class you add to this folder will be in root_namespace.Abc namespace)

aku
+1  A: 

This is entirely personal preference. I would choose the latter.

Ask yourself the question, "Am I adding any useful information by repeating Foo and Bar in the sub-folders?" The answer here, in my opinion, is no, simply because the information is redundant. You've also created yourself a maintenance problem; if you need to rename Bar you now have to rename Foo.Bar, Foo.Bar.View, Foo.Bar.Model ...

Patrick Johnmeyer
A: 

Foo/Bar/View seems a better choice, more if individual files are named as the individual types (e.g. Foo.Bar.View.IView => Foo/Bar/View/IView.cs).

That's a great pattern to follow, which makes it easier to find types, scripting over sources, do some metrics, etc.

Ariel