PC Review


Reply
Thread Tools Rate Thread

Assembly name vs. Namespace name

 
 
Vagif Abilov
Guest
Posts: n/a
 
      30th Jan 2005
I've recently read guidelines where it is recommended to organize projects
in directories that match assembly names. For example, if I have an assembly
called MyCompany.MyProduct.Data, then I should have the following folder
structure on my local disk and in version control system:

MyCompany
MyProduct
Data

Inside the innermost folder I will place a C# project that is called
MyCompany.MyProduct.Data.csproj

Then for each type/class defined in the project I will have a file with
class name.

I believe this is a very consistent approach, although I find recommendation
to create one file per enumeration type to be a bit extreme. However I am
bit confused if I should use assembly name or namespace name as a base for
my folders, and if assembly names and namespaces should have different
structure at all. What is your approach to namespace naming? Are there any
reasons they should not be different, i.e. a namespace should not be
assigned a name of its assembly? I have looked at our projects and in
principle it looks that we can unify their namespaces, so they will match
respective assembly names. It this a good idea?

Vagif Abilov
vagif @online.no
Oslo Norway


 
Reply With Quote
 
 
 
 
B S Wootton
Guest
Posts: n/a
 
      31st Jan 2005

"Vagif Abilov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I've recently read guidelines where it is recommended to organize projects
> in directories that match assembly names. For example, if I have an

assembly
> called MyCompany.MyProduct.Data, then I should have the following folder
> structure on my local disk and in version control system:
>
> MyCompany
> MyProduct
> Data
>


<SNIP>

As with many things it is a matter of personal choice, but my 2p is that
organising into directories like that
based on assembly names is horrible! It's common in Java because a
dot-seperated typename is resolved
by traversing corresponding directories, but I haven't seen it in any .NET
projects.

I'd instead go with a seperation based on functionality of the code. This
may or may not match your
namespaces. Dividing into core/gui/tests is one strategy that I use often.
YMMV.

Ben



 
Reply With Quote
 
Vagif Abilov
Guest
Posts: n/a
 
      31st Jan 2005
But do your assembly names match namespaces?


"B S Wootton" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Vagif Abilov" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I've recently read guidelines where it is recommended to organize
>> projects
>> in directories that match assembly names. For example, if I have an

> assembly
>> called MyCompany.MyProduct.Data, then I should have the following folder
>> structure on my local disk and in version control system:
>>
>> MyCompany
>> MyProduct
>> Data
>>

>
> <SNIP>
>
> As with many things it is a matter of personal choice, but my 2p is that
> organising into directories like that
> based on assembly names is horrible! It's common in Java because a
> dot-seperated typename is resolved
> by traversing corresponding directories, but I haven't seen it in any .NET
> projects.
>
> I'd instead go with a seperation based on functionality of the code. This
> may or may not match your
> namespaces. Dividing into core/gui/tests is one strategy that I use
> often.
> YMMV.
>
> Ben
>
>
>



 
Reply With Quote
 
B S Wootton
Guest
Posts: n/a
 
      31st Jan 2005
"Vagif Abilov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> But do your assembly names match namespaces?
>


No, I would typically have many sub-namespaces in a given assembly. For
instance:

ben.core.dll:
- ben.core
- ben.core.remoting
- ben.core.logging

ben.gui:
- ben.gui.serialisation
- ben.gui

This is because my applications are usually driven like this. If you would
like to say, divide your logging stuff out for future use, by all means
refactor this into a seperate assembly. In this situaiton I would choose to
put it into a different directory based on it's function - rather than it's
namespace or assembly name.

Again, just my suggestion.

It might be worth downloading some large .NET open source frameworks and
seeing if you like their internal organisation. That's what I did!

Ben


 
Reply With Quote
 
Vagif Abilov
Guest
Posts: n/a
 
      31st Jan 2005
Thank you Ben. I am currently looking at some examples from large projects.
Looks like we will go for "one namespace per assembly" approach.

Vagif


"B S Wootton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Vagif Abilov" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> But do your assembly names match namespaces?
>>

>
> No, I would typically have many sub-namespaces in a given assembly. For
> instance:
>
> ben.core.dll:
> - ben.core
> - ben.core.remoting
> - ben.core.logging
>
> ben.gui:
> - ben.gui.serialisation
> - ben.gui
>
> This is because my applications are usually driven like this. If you
> would
> like to say, divide your logging stuff out for future use, by all means
> refactor this into a seperate assembly. In this situaiton I would choose
> to
> put it into a different directory based on it's function - rather than
> it's
> namespace or assembly name.
>
> Again, just my suggestion.
>
> It might be worth downloading some large .NET open source frameworks and
> seeing if you like their internal organisation. That's what I did!
>
> Ben
>
>



 
Reply With Quote
 
Michael S
Guest
Posts: n/a
 
      1st Feb 2005

"Vagif Abilov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thank you Ben. I am currently looking at some examples from large
> projects. Looks like we will go for "one namespace per assembly" approach.


I think you should reconsider.

I have found that going for a one-one relationship between assemblys and
namespaces almost defeats the purpose of using namespaces in the first place
(except for solving ambiguous classnames).

For large SOA projects I typically define assemlies per Facade, ie a can
have a customer and a order dll.
If I want to have entity validaors in several tier and or datasets on
several tiers I wrap them in separate assemblies.

However, my namespace/assembly group might look something like this (a
simple example):

customer.facade (customer.dll)
customer.data (dto.dll)
customer.validation (validator.dll)
order.facade (order.dll)
order.data (dto.dll)
order.validation (validator.dll)

Hence, I use namespaces to structure my code and assemblies to structure my
tiers and layers.

Hope this helps
- Michael S






 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
type or namespace name 'MessageBox' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) mp Microsoft C# .NET 8 18th Dec 2010 05:55 AM
ERROR CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC' (are you missing an assembly reference?) li.eddie@gmail.com Microsoft ASP .NET 0 6th Jan 2006 11:31 AM
ASP.NET 2.0: What is the namespace and assembly name of generated assembly SA Microsoft ASP .NET 0 9th Aug 2004 06:09 PM
Get All Namespace used in a Assembly Kiran Microsoft C# .NET 7 27th Apr 2004 07:02 AM
The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?) =?Utf-8?B?UmF5?= Microsoft Dot NET 1 7th Apr 2004 10:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.