472,988 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 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 3565

"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.