class / namespace hierarchy issue - don't want same name twice

Z

Zytan

I want to have a Win32 class (to dump my win32 dll imports in). I
want this in it's own directory Win32 in the solution explorer (since
I have other classes to put in this folder), which makes Win32 a
namespace. So, this ends up with:

MyProgramName.Win32.Win32.SendMessage
MyProgramName.Win32.AnotherClass.SomeWrapper

MyProgramName = my program's name
(1st) Win32 = namespace made from the folder
(2nd) Win32, AnotherClass = class names
SendMessage, SomeWrapper = methods

Is this proper? I'd rather have only one Win32 in the first example,
but that implies the namespace and classname must be one, which makes
no sense. I believe I've seen this exact thing in the .NET framework,
and I believe I was warned about how this appears strange to newbies,
so I think it is proper.

any thoughts welcome,
Zytan
 
N

Nicholas Paldino [.NET/C# MVP]

The namespace is dictated in the file that the class is defined in, not
the directory that the file is in. You can place whatever classes in
whatever directories you wish, and then make the namespace anything you
wish. There doesn't have to be any correlation between the two.

Perhaps you should think of another classname other than the namespace
name? Also, if you are providing a managed wrapper for windows apis, this
naming convention will probably help:

http://msdn2.microsoft.com/en-us/library/btadwd4w(vs.80).aspx
 
Z

Zytan

The namespace is dictated in the file that the class is defined in, not
the directory that the file is in. You can place whatever classes in
whatever directories you wish, and then make the namespace anything you
wish. There doesn't have to be any correlation between the two.

Yes, I know. But since the IDE does this for me when I create new
files in the solution explorer folders, I figured that I'd follow
suit. Also, since when you delete a file from solution explorer it
deletes the file from the HD as well! So, it seems that they really
want us to follow suit! (Which make it difficult to deal with if you
update your program on more than one PC, and bring it back and forth,
unless you copy the whole directory each time)
Perhaps you should think of another classname other than the namespace
name?

Perhaps I should. But, I am correct when I say that even the NET
framework uses the same name sometimes, right? So, it's not so bad, I
think. But, yes, there may be a better way.
Also, if you are providing a managed wrapper for windows apis, this
naming convention will probably help:

http://msdn2.microsoft.com/en-us/library/btadwd4w(vs.80).aspx

Ok, thanks!

Zytan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top