Home > Microsoft .Net Development Tips > .NET Architecture > Project structure best practices
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET ARCHITECTURE

Project structure best practices


Jim Mischel
10.05.2004
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


The .NET Framework is designed to allow tight integration with development tools, and Visual Studio .NET has many features that work closely with the Framework to ease the application development process. In addition, Visual Studio .NET default settings encourage implementation of best practice recommendations. Even with the defaults, there are things that you should know before you start a team project, or any production project for that matter. This article from InformIT's .NET Reference Guide outlines a set of best practices for structuring development projects.


There are several different ways that you can structure your solutions and projects. The most common method is a single solution that contains multiple projects. This model works well for small and medium-large systems that consist of one or more project assemblies. It allows each member of your development team access to all of the projects in the solution, allowing them to build and deploy the entire solution on their local workstations. The single-solution has the following primary advantages and disadvantages:

  • When you need to reference another assembly generated by a separate project, you can use a project reference. Project references are the preferred way to establish references to other assemblies and they are guaranteed to work on all development workstations in a team environment. In addition, because project references are sensitive to changes in the configuration of the referenced project, you can automatically switch from Debug and Release builds across projects without having to reset references.
  • Assembly versioning issues are avoided, because Visual Studio .NET detects when a client of a referenced assembly needs to be rebuilt.
  • The system build process and build script is much simpler.
  • The model scales only so far. If you want to work on a single project within the solution, you are forced to acquire all of the source code for all projects within the solution.
  • Due to project dependencies, even minor (non-breaking) changes to a single source file within a single project can result in a rebuild of many projects within the solution. If an assembly's interface changes within a referenced project, you want the client project to be rebuilt. However, unnecessary rebuilds can be very time consuming, especially for solutions containing many projects.

Note that with the last two, there is no hard and fast rule as to how big is "too big." In general, you should be able to comfortably work with a single solution that contains 10 to 20 projects. The maximum number of workable projects in a single solution is hard to define, because it depends on your build server and workstation specifications, the size and number of source files in individual projects, and the dependencies between your projects.

There are two other common solution structures. The partitioned single solution is recommended for projects that are too large to comfortably fit within a single solution model. This model breaks a master solution into multiple sub-solutions so that they are easier to work with. In this model, projects often are members of multiple solutions. This model requires more maintenance and care in order to ensure that new projects are added to the appropriate sub-solutions and references are updated appropriately. This model also can be difficult to maintain in source control.

With the multi-solution model, you create individual solutions to group projects in logical or functional areas, and no project is contained in more than one solution. This model allows you to avoid the additional overhead of adding projects to multiple solutions, but forces you to use file references rather than the preferred project references. In addition, assembly versioning becomes an issue when a project references an assembly that is in a different solution.

Whatever model you choose for your particular application, you should ensure that all team members create identical directory structures on their development machines. Define a single root directory for all projects and create a sub-folder for each solution. Projects become child folders of the solution folder. This allows all developers all developers to quickly and easily locate the solution's files in VSS and on each other's development machines. Life in a team environment is difficult enough without adding unnecessary hunting for things.

The most important thing to remember about source control is always to use Visual Studio .NET to create and manipulate your projects and solutions in VSS. Visual Studio .NET ensures that only the appropriate files are placed under source control, and that files are updated with the proper VSS-specific information whenever they are checked in, checked out, or copied. Manipulating your solution with the VSS Explorer is a recipe for disaster. When you place a solution or project under source control, Visual Studio .NET adds the following file types to VSS:

  • Solution files (*.sln)
  • Project files (*.csproj, *.vbproj, etc)
  • Application configuration files (Web.config or App.config)
  • Source files (*.cs, *.vb, *.aspx, *.asax, *.resx, etc.)

Visual Studio .NET creates many other types of files on developer workstations and on the build server. These include solution user options, project user options, webinfo files, and project build outputs. These files are not placed under source control.


Read more about .NET project structures at InformIT's .NET Reference Guide.


Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
.NET Architecture
Microsoft's Oslo modeling platform, the M language and .NET
Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
Free book from Microsoft brings patterns and practices to .NET
A look at concurrency constructs and primitives in .NET
Designing Windows Communication Foundation service contracts
Book excerpt: Java EE and .NET security interoperability
Book excerpt: .NET Framework Design Guidelines
Book Excerpt: Executing activities in Windows Workflow Foundation
Aspect-oriented programming (AOP) and the .NET Framework
Book excerpt: Hands-on Windows Communication Foundation

.NET Architecture Best Practices
Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
Free book from Microsoft brings patterns and practices to .NET
Java application frameworks come to .NET
The faces of .NET/Java interoperability
.NET Development coming to a Cloud near you
Distributed caching goes mainstream
A look at concurrency constructs and primitives in .NET
Designing Windows Communication Foundation service contracts
Scaling WCF applications can challenge development teams
Microsoft touts rich Internet app development at Mix08
.NET Architecture Best Practices Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
.NET  (SearchWinDevelopment.com)
C#  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts