Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Howdy,

 

I have a class called DBResult, which resides in the namespace Stitch.Database. There is another class in the Stitch.Database namespace, and an enum with three values.

 

Should I keep each class in a seperate file? What about the enum? And whats a general way to name the files?

 

For instance, should DBResult reside in the file Stitch.Database.DBResult.cs?

 

Thanks for any help :)

  • *Experts*
Posted

Generally, each namespace is a separate folder and you have one class per file. There's no hard and fast rule though - it's up to you.

 

If classes are VERY related it's generally a good idea to keep them together in the same file. You may also want them in the same file if they're very small.

 

Personally, I like every class in its own file with a few, very rare exceptions.

 

For namespaces, assume your project is in c:\projects\Stitch. There should be a folder named c:\projects\Stitch\Database and the DBResult.cs lives in this folder.

 

If you create the folders in Visual Studio and then add a file, the new class will have it's namespace default to using the folder name as an added level to the namespace.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...