473,386 Members | 1,720 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,386 software developers and data experts.

.NET project structure best practices

We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder
structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for specific
assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is
placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions. According
to Microsoft's recommendations, we will place it under MyCompany.Data. This
means on developer's machine the folder MyCompany.Data will not only contain
source files and binaries owned by MyCompany.Data assembly, but will also
have a sub-folder SqlServer that has nothing to do with MyCompany.Data
project. It's not a sub-project, but it will be placed in a subfolder simply
because it's namespace has MyCompany.Data in it's root.

2. Web projects. Here we have the same situation, but with possibly more
serious consequences. Web projects may have many sub-folders with resources,
images, scripts etc. Placing sub-folders there is misleading - it looks like
sub-project is a part of a Web site (and it may even be copied using XCOPY
deployment), but in fact it has nothing to do with the Web site. Again it
just has co-related namespace.

We haven't found so far an elegant resolutions to these problems. If
somebody follows the guidelines above and has some ideas about how to handle
this, please let me know.

Thanks in advance

Vagif Abilov
Oslo Norway
Jul 21 '05 #1
6 3591

"Vagif Abilov" <va***@online.no> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder
structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for
specific assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is
placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions.
According to Microsoft's recommendations, we will place it under
MyCompany.Data. This means on developer's machine the folder
MyCompany.Data will not only contain source files and binaries owned by
MyCompany.Data assembly, but will also have a sub-folder SqlServer that
has nothing to do with MyCompany.Data project. It's not a sub-project, but
it will be placed in a subfolder simply because it's namespace has
MyCompany.Data in it's root.
No. If MyCompany.Data.SqlServer is a seperate assembly then it goes in a
seperate project and a seperate folder structure:

c:\projects\MyCompany.Data\MyCompany\Data\*.cs

c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

Although I would disagree with this guidance. It stinks of Java. Each
assembly should have a root namespace. For instance MyCompany.Data should
have a root namespace of MyCompany.Data, duh. Then in the project folder
for MyCompany.Data classes in the MyCompany.Data namespace should appear in
the root of the project folder. If the assembly also has classes in the
MyCompany.Data.Common namespace, they should go in a "Common" subfolder:

c:\projects\MyCompany.Data\*.cs
c:\projects\MyCompany.Data\Common\*.cs


2. Web projects. Here we have the same situation, but with possibly more
serious consequences. Web projects may have many sub-folders with
resources, images, scripts etc. Placing sub-folders there is misleading -
it looks like sub-project is a part of a Web site (and it may even be
copied using XCOPY deployment), but in fact it has nothing to do with the
Web site. Again it just has co-related namespace.


You can resolve this with factoring out most of your web project code to a
seperate project. The code behind files go in the web project, and perhaps
a couple of utility classes, but any substantial amount of code should go in
a seperate assembly.

David
Jul 21 '05 #2
c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

This does not make sense to me. I agree it would be nice to place each
project in its own folder, but why creating all these subfolders in
c:\projects\MyCompany.Data.SqlServer? I see your point, but I would swap
prefix and suffix:

c:\projects\MyCompany\Data\SqlServer\MyCompany.Dat a.SqlServer\*.cs

Then the folder c:\projects\MyCompany\Data\ can be used as a root for other
projects with namespace derived from MyCompany.Data.

Just my 2 cents
Vagif
"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...

"Vagif Abilov" <va***@online.no> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder
structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for
specific assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is
placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions.
According to Microsoft's recommendations, we will place it under
MyCompany.Data. This means on developer's machine the folder
MyCompany.Data will not only contain source files and binaries owned by
MyCompany.Data assembly, but will also have a sub-folder SqlServer that
has nothing to do with MyCompany.Data project. It's not a sub-project,
but it will be placed in a subfolder simply because it's namespace has
MyCompany.Data in it's root.


No. If MyCompany.Data.SqlServer is a seperate assembly then it goes in a
seperate project and a seperate folder structure:

c:\projects\MyCompany.Data\MyCompany\Data\*.cs

c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

Although I would disagree with this guidance. It stinks of Java. Each
assembly should have a root namespace. For instance MyCompany.Data should
have a root namespace of MyCompany.Data, duh. Then in the project folder
for MyCompany.Data classes in the MyCompany.Data namespace should appear
in the root of the project folder. If the assembly also has classes in
the MyCompany.Data.Common namespace, they should go in a "Common"
subfolder:

c:\projects\MyCompany.Data\*.cs
c:\projects\MyCompany.Data\Common\*.cs


2. Web projects. Here we have the same situation, but with possibly more
serious consequences. Web projects may have many sub-folders with
resources, images, scripts etc. Placing sub-folders there is misleading -
it looks like sub-project is a part of a Web site (and it may even be
copied using XCOPY deployment), but in fact it has nothing to do with the
Web site. Again it just has co-related namespace.


You can resolve this with factoring out most of your web project code to a
seperate project. The code behind files go in the web project, and
perhaps a couple of utility classes, but any substantial amount of code
should go in a seperate assembly.

David

Jul 21 '05 #3
My two cents. The last thing you want is a deep dir structure. You want it
wide, not deep. So having nesting is just a major pain if you ask me. Make
things simple. Each project has it own directory in the root project dir -
period. If you create containers in your projects to logically orginize
stuff, fine. Also create a "subst" drive to your project directory for easy
access from the command line (I use V:). If your at the command line, last
thing you want to do is surf dirs to find stuff.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Vagif Abilov" <va***@online.no> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

This does not make sense to me. I agree it would be nice to place each
project in its own folder, but why creating all these subfolders in
c:\projects\MyCompany.Data.SqlServer? I see your point, but I would swap
prefix and suffix:

c:\projects\MyCompany\Data\SqlServer\MyCompany.Dat a.SqlServer\*.cs

Then the folder c:\projects\MyCompany\Data\ can be used as a root for other projects with namespace derived from MyCompany.Data.

Just my 2 cents
Vagif
"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...

"Vagif Abilov" <va***@online.no> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for
specific assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions.
According to Microsoft's recommendations, we will place it under
MyCompany.Data. This means on developer's machine the folder
MyCompany.Data will not only contain source files and binaries owned by
MyCompany.Data assembly, but will also have a sub-folder SqlServer that
has nothing to do with MyCompany.Data project. It's not a sub-project,
but it will be placed in a subfolder simply because it's namespace has
MyCompany.Data in it's root.


No. If MyCompany.Data.SqlServer is a seperate assembly then it goes in a seperate project and a seperate folder structure:

c:\projects\MyCompany.Data\MyCompany\Data\*.cs

c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

Although I would disagree with this guidance. It stinks of Java. Each
assembly should have a root namespace. For instance MyCompany.Data should have a root namespace of MyCompany.Data, duh. Then in the project folder for MyCompany.Data classes in the MyCompany.Data namespace should appear
in the root of the project folder. If the assembly also has classes in
the MyCompany.Data.Common namespace, they should go in a "Common"
subfolder:

c:\projects\MyCompany.Data\*.cs
c:\projects\MyCompany.Data\Common\*.cs


2. Web projects. Here we have the same situation, but with possibly more serious consequences. Web projects may have many sub-folders with
resources, images, scripts etc. Placing sub-folders there is misleading - it looks like sub-project is a part of a Web site (and it may even be
copied using XCOPY deployment), but in fact it has nothing to do with the Web site. Again it just has co-related namespace.


You can resolve this with factoring out most of your web project code to a seperate project. The code behind files go in the web project, and
perhaps a couple of utility classes, but any substantial amount of code
should go in a seperate assembly.

David



Jul 21 '05 #4
This must be one of the worst idea I've seen in a long time!!

I just create my directories under my "Projects" directory. The directory
has the same name as the namespace.

"Vagif Abilov" <va***@online.no> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder
structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for specific assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is
placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions. According to Microsoft's recommendations, we will place it under MyCompany.Data. This means on developer's machine the folder MyCompany.Data will not only contain source files and binaries owned by MyCompany.Data assembly, but will also
have a sub-folder SqlServer that has nothing to do with MyCompany.Data
project. It's not a sub-project, but it will be placed in a subfolder simply because it's namespace has MyCompany.Data in it's root.

2. Web projects. Here we have the same situation, but with possibly more
serious consequences. Web projects may have many sub-folders with resources, images, scripts etc. Placing sub-folders there is misleading - it looks like sub-project is a part of a Web site (and it may even be copied using XCOPY
deployment), but in fact it has nothing to do with the Web site. Again it
just has co-related namespace.

We haven't found so far an elegant resolutions to these problems. If
somebody follows the guidelines above and has some ideas about how to handle this, please let me know.

Thanks in advance

Vagif Abilov
Oslo Norway

Jul 21 '05 #5
Thanks William,

Yes, this is one option: all assemblies are siblings. It's a question then
if it's consistent to make Web projects and Web services siblings or
standard assemblies, and there are auxilliary projects, tools, tests etc. So
it will quickly grow up to a hundred of siblings even for a small company.
But I see your point.

Vagif
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:Ov**************@TK2MSFTNGP15.phx.gbl...
My two cents. The last thing you want is a deep dir structure. You want
it
wide, not deep. So having nesting is just a major pain if you ask me.
Make
things simple. Each project has it own directory in the root project
dir -
period. If you create containers in your projects to logically orginize
stuff, fine. Also create a "subst" drive to your project directory for
easy
access from the command line (I use V:). If your at the command line,
last
thing you want to do is surf dirs to find stuff.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Vagif Abilov" <va***@online.no> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs

This does not make sense to me. I agree it would be nice to place each
project in its own folder, but why creating all these subfolders in
c:\projects\MyCompany.Data.SqlServer? I see your point, but I would swap
prefix and suffix:

c:\projects\MyCompany\Data\SqlServer\MyCompany.Dat a.SqlServer\*.cs

Then the folder c:\projects\MyCompany\Data\ can be used as a root for

other
projects with namespace derived from MyCompany.Data.

Just my 2 cents
Vagif
"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
>
> "Vagif Abilov" <va***@online.no> wrote in message
> news:O1**************@TK2MSFTNGP10.phx.gbl...
>> We decided to adopt .NET coding guidelines posted by Brad Abrams from
>> Microsoft:
>> http://blogs.msdn.com/brada/archive/...26/361369.aspx
>>
>> Here is what Brad (and AFAIK Microsoft) suggests regarding project folder >> structure:
>>
>> "Directory names should follow the namespace for the class
>> For example, I would expect to find the public class
>> "System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."
>>
>> Sounds logical, and it simplifies search for projects and files for
>> specific assembly. However we found two main issues:
>>
>> 1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is >> placed in a folder MyCompany.Data and stored in version control
>> sysmtem
>> using the same folder structure. Now we create another project, called
>> MyCompany.Data.SqlServer to manage SQL Server-specific functions.
>> According to Microsoft's recommendations, we will place it under
>> MyCompany.Data. This means on developer's machine the folder
>> MyCompany.Data will not only contain source files and binaries owned
>> by
>> MyCompany.Data assembly, but will also have a sub-folder SqlServer
>> that
>> has nothing to do with MyCompany.Data project. It's not a sub-project,
>> but it will be placed in a subfolder simply because it's namespace has
>> MyCompany.Data in it's root.
>
> No. If MyCompany.Data.SqlServer is a seperate assembly then it goes in a > seperate project and a seperate folder structure:
>
> c:\projects\MyCompany.Data\MyCompany\Data\*.cs
>
> c:\projects\MyCompany.Data.SqlServer\MyCompany\Dat a\SqlServer\*.cs
>
> Although I would disagree with this guidance. It stinks of Java. Each
> assembly should have a root namespace. For instance MyCompany.Data should > have a root namespace of MyCompany.Data, duh. Then in the project folder > for MyCompany.Data classes in the MyCompany.Data namespace should
> appear
> in the root of the project folder. If the assembly also has classes in
> the MyCompany.Data.Common namespace, they should go in a "Common"
> subfolder:
>
> c:\projects\MyCompany.Data\*.cs
> c:\projects\MyCompany.Data\Common\*.cs
>
>
>>
>> 2. Web projects. Here we have the same situation, but with possibly more >> serious consequences. Web projects may have many sub-folders with
>> resources, images, scripts etc. Placing sub-folders there is misleading - >> it looks like sub-project is a part of a Web site (and it may even be
>> copied using XCOPY deployment), but in fact it has nothing to do with the >> Web site. Again it just has co-related namespace.
>
> You can resolve this with factoring out most of your web project code
> to a > seperate project. The code behind files go in the web project, and
> perhaps a couple of utility classes, but any substantial amount of code
> should go in a seperate assembly.
>
> David
>


Jul 21 '05 #6
What about Web projects then? Web services, tools, tests? Also on the same
level?

Vagif

"Relaxin" <so*******@amer.com> wrote in message
news:uM*************@TK2MSFTNGP10.phx.gbl...
This must be one of the worst idea I've seen in a long time!!

I just create my directories under my "Projects" directory. The directory
has the same name as the namespace.

"Vagif Abilov" <va***@online.no> wrote in message
news:O1**************@TK2MSFTNGP10.phx.gbl...
We decided to adopt .NET coding guidelines posted by Brad Abrams from
Microsoft:
http://blogs.msdn.com/brada/archive/...26/361369.aspx

Here is what Brad (and AFAIK Microsoft) suggests regarding project folder
structure:

"Directory names should follow the namespace for the class
For example, I would expect to find the public class
"System.Windows.Forms.Control" in "System\Windows\Forms\Control.cs"."

Sounds logical, and it simplifies search for projects and files for

specific
assembly. However we found two main issues:

1. Non-Web projects. Let's say we have an assembly MyCompany.Data. It is
placed in a folder MyCompany.Data and stored in version control sysmtem
using the same folder structure. Now we create another project, called
MyCompany.Data.SqlServer to manage SQL Server-specific functions.

According
to Microsoft's recommendations, we will place it under MyCompany.Data.

This
means on developer's machine the folder MyCompany.Data will not only

contain
source files and binaries owned by MyCompany.Data assembly, but will also
have a sub-folder SqlServer that has nothing to do with MyCompany.Data
project. It's not a sub-project, but it will be placed in a subfolder

simply
because it's namespace has MyCompany.Data in it's root.

2. Web projects. Here we have the same situation, but with possibly more
serious consequences. Web projects may have many sub-folders with

resources,
images, scripts etc. Placing sub-folders there is misleading - it looks

like
sub-project is a part of a Web site (and it may even be copied using
XCOPY
deployment), but in fact it has nothing to do with the Web site. Again it
just has co-related namespace.

We haven't found so far an elegant resolutions to these problems. If
somebody follows the guidelines above and has some ideas about how to

handle
this, please let me know.

Thanks in advance

Vagif Abilov
Oslo Norway


Jul 21 '05 #7

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

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
7
by: Andrew Hayes | last post by:
Hi All, I've been asked to develop an online ASP version of our HR product in 3 months, and only with part-time support from a database developer in the US. The original product is written in...
1
by: Vincent V | last post by:
Hey i am just starting a new project and from the start i want to make sure my app is as Object Orientated as possible I have a couple of questions in relation to this Question 1: Should i...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
6
by: Vagif Abilov | last post by:
We decided to adopt .NET coding guidelines posted by Brad Abrams from Microsoft: http://blogs.msdn.com/brada/archive/2005/01/26/361369.aspx Here is what Brad (and AFAIK Microsoft) suggests...
0
by: Louis Aslett | last post by:
I hope this is the correct newsgroup for this query (if not please give me a pointer to where is best): I understand the theory of normalisation etc and am trying to follow best practices in the...
5
by: BK | last post by:
We've got a fairly large scale development process under way in .NET 2003. We are about a month away from go-live for phase 1, second phase is rather short and all work should be completed in the...
2
by: CK | last post by:
Good Morning All, What the best way to use references? Reference a project in another project or reference a DLL. We are developing C# Sharp Web Apps in VS 2003. We are getting warnings like the...
2
by: Max2006 | last post by:
Hi, Is there any MSDN or industry standard article that recommends best practices for namespace naming and assembly names? I like to have assembly names same as the base namespace name within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.