473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Should namespace hierarchy reflect the folder hierarchy on the disk

I did try to search this in old posts, but could not find it.

I suppose it is ok to ask beginner level questions here, unlike other
groups, demarcated for beginners and experts.

Suppose I create a class in a namespace, MyNamespace.Trials.

Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files there. Or I
can keep them anywhere on the disk.

Also, once I tried making a simple geometry point class, and it would
not compile.

class CSPoint
{
int x;
int y;
//ideally should be double, in a 3d space,
//but just for testing sake, it is 2 ints in a plane

//getter and setter methods.
}

I needed to add a Main. Why is this so.

I come from a Java background.
Thanks.

Nov 17 '05 #1
5 2109
HalcyonWild,

I tried using that heiarchical structure, but I found that it was overly
complicated for projects to reference each other in a solution.

I flatten the heiarchy, and have one directory for each distinct
namespace, so my solution directories will have the following project
directories:

Casper
Casper.Remoting
Casper.Drawing

And so on. In your case, you would have a MyNamespace directory, as
well as a MyNamespace.Trials directory. It will make it much easier as you
have more namespaces, and they start referencing each other.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"HalcyonWild" <Ha**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I did try to search this in old posts, but could not find it.

I suppose it is ok to ask beginner level questions here, unlike other
groups, demarcated for beginners and experts.

Suppose I create a class in a namespace, MyNamespace.Trials.

Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files there. Or I
can keep them anywhere on the disk.

Also, once I tried making a simple geometry point class, and it would
not compile.

class CSPoint
{
int x;
int y;
//ideally should be double, in a 3d space,
//but just for testing sake, it is 2 ints in a plane

//getter and setter methods.
}

I needed to add a Main. Why is this so.

I come from a Java background.
Thanks.

Nov 17 '05 #2
HalcyonWild wrote:
Suppose I create a class in a namespace, MyNamespace.Trials.
Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files
there. Or I can keep them anywhere on the disk.
There is no such technical restriction (you can keep them anywhere), but it
is widely regarded as a good practice and makes things easier to find.
Also, once I tried making a simple geometry point class, and it would
not compile. I needed to add a Main. Why is this so.


Your project type was an executable, rather than a class library.
Executables need an entry point.

--
Chris Priede
Nov 17 '05 #3

Chris Priede wrote:
HalcyonWild wrote:
Suppose I create a class in a namespace, MyNamespace.Trials.
Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files
there. Or I can keep them anywhere on the disk.


There is no such technical restriction (you can keep them anywhere), but it
is widely regarded as a good practice and makes things easier to find.
Also, once I tried making a simple geometry point class, and it would
not compile. I needed to add a Main. Why is this so.


Your project type was an executable, rather than a class library.
Executables need an entry point.

--
Chris Priede

Thanks for the quick responses, Chris and Nicholas,

So as I understand it, it is not a restriction from the language side,
to maintain namespace hierarchy in the paths on the disk. But we do it
just for easy maintainability.

So I can keep all my .exe files at one place on the disk, even though
the namespaces are different. I should however maintain folder
hierarchy on disk for easy tracking. Please correct me if I am wrong.

I think that must be a compiler switch, to compile a .cs into a class
library rather than executable. Will look for it. Also Chris, I do not
have visual studio.net. I am using the cmdline compilers with the
framework.

Also, assemblies are something like jars, (from what I searched and
found, not really sure about this), and you normally name assemblies
like namespaces, as a good practice. More questions on this later if I
have any problems. I will try this out.

Thanks.

Nov 17 '05 #4

Chris Priede wrote:
HalcyonWild wrote:
Suppose I create a class in a namespace, MyNamespace.Trials.
Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files
there. Or I can keep them anywhere on the disk.


There is no such technical restriction (you can keep them anywhere), but it
is widely regarded as a good practice and makes things easier to find.

As an afterthought, I think this is a great feature. No need to take
care of classpaths, imports , package hierarchies on disk, like in
Java.

Nov 17 '05 #5
No one os your physical hardisk hierarchy and the other your logical
class heirarchy no relation

-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book

http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave Slinn | last post by:
Any advice on how to organize my core class library project into sub-namespaces? What are the general rules of thumb regarding cross-namespace references? Can I have a class in namespace A have a...
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
7
by: Hani Atassi | last post by:
I developed a client side control using Windows Forms and I want to deploy it through IE inside an ASP.NET project. I am using the object tag to deploy: <OBJECT id="SSFileCtrl1"...
3
by: Charlie | last post by:
I am fairly new to VB.NET and was wondering if anyone knew where to find a complete listing of the namespaces in VB.NET and MSDN Library. I would really like to see a listing or a "catalog" of...
14
by: ToddLMorgan | last post by:
Summary: How should multiple (related) projects be arranged (structured) and configured so that the following is possible: o Sharing common code (one of the projects would be a "common" project...
5
by: Jonathan Wood | last post by:
Greetings, Normally, when I create C# modules, the class appears within a namespace. However, I've just created a Web service and new classes have no namespace. Can anyone tell me why this...
2
by: Zytan | last post by:
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...
11
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a machine Windows Server 2003 using IIS 6.0 and I am getting the error BC30560 prjob_ascx is ambiguous in the namespace ASP I found a fix. Deleting all the files in the...
6
by: =?Utf-8?B?RGljaw==?= | last post by:
Please can you tell me how to assign a namespace to a resource file in a Visual Basic project? In C# such resources file inherit their namespace based upon the folder hierarchy in which they are...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.