Rule #1
Do you have a consistent .NET Solution Structure?
  v6.0 Posted at 16/08/2012 6:01 PM by ulyssesmaclaren

When developing a n-tiered software solution, we follow a standard solution structure. We have incorporated unit testing components, which is an integral part of the Extreme Programming development methodology, into our solution structure:

Project Type Project Name Note
Application Northwind
Namespace: SSW.Northwind
Folder: SSW\Northwind\Northwind\
Output: Northwind.exe
Class Library WindowsUI
Namespace: SSW.Northwind.WindowsUI
Folder: SSW\Northwind\WindowsUI\
Folder: SSW\Northwind\WindowsUI.Tests
Output: WindowsUI.dll
We put all the forms in a separate project so we can run Unit Tests on the UI using reflection.Note if you have two projects you will give them different names (e.g. ProductSilverlightUI and AdminWebUI)
Application ConsoleUI
Namespace: SSW.Northwind.ConsoleUI
Folder: SSW\Northwind\ConsoleUI\
Folder: SSW\Northwind\ConsoleUI.Tests
Output: NorthwindConsole.exe
Application SilverlightUI
Namespace: SSW.Northwind.SilverlightUI
Folder: SSW\Northwind\SilverlightUI\
Folder: SSW\Northwind\SilverlightUI.Tests
Output: SSW.Northwind.SilverlightUI.dll
Application WebUI
Namespace: SSW.Northwind.WebUI
Folder: SSW\Northwind\WebUI\
Folder: SSW\Northwind\WebUI\UnitTests
Output: SSW.Northwind.WebUI.dll
Namespace: SSW.Northwind.WebUI.Reports
Folder: SSW\Northwind\WebUI\Reports\

Manually-based reports - e.g. using the DataGrid .

Part of WebUI. For .css and .ascx user controls

Windows Service WindowsService
Folder: SSW\Northwind\WindowsService\Components
Folder: SSW\Northwind\WindowsService.Tests
Output: SSW.Northwind.WindowsService.dll
RS Reports Reports
Namespace: N/A
Folder: SSW\Northwind\Reports
Output: N/A

Reporting Services

Note: We don't use Reports2005 or Reports2008 indicating the version number of reporting services because renaming in version control is a process intensive operation

Class Library IServices
Namespace: SSW.Northwind.IServices
Folder: SSW\Northwind\IServices
Folder: SSW\Northwind\IServices.Tests
Output: SSW.Northwind.IServices.dll

WCF Services Interfaces

Note: only use if you are not hosting WCF in IIS

Class Library Services
Namespace: SSW.Northwind.Services
Folder: SSW\Northwind\Services
Folder: SSW\Northwind\Services.Tests
Output: SSW.Northwind.Services.dll

WCF Services Implementations

Note: If you use WCF IIS Activation then you can put these under WebUI/Services to make deployment easier

Class Library Business
Namespace: SSW.Northwind.Business
Folder: SSW\Northwind\Business\
Folder: SSW\Northwind\Business\Components
Folder: SSW\Northwind\Business\UnitTests
Output: SSW.Northwind.Business.dll

This can be code-generated

(REPLACED BY SERVICES)

Class Library Domain
Namespace: SSW.Northwind.Domain
Folder: SSW\Northwind\Domain
Folder: SSW\Northwind\Domain.Tests
Output: SSW.Northwind.Domain.dll

LINQ .EDMX AND .DBML sit here - this can be generated using SQL Metal (Replaces DataAccess and DataSets)

Note: LINQ to Entities is preferred over LINQ to SQL

Class Library DataSets
Namespace: SSW.Northwind.DataSets
Folder: SSW\Northwind\DataSets\
Folder: SSW\Northwind\DataSets\UnitTests
Output:> SSW.Northwind.DataSets.dll

Strongly typed datasets - this can be code-generated

(REPLACED BY DOMAIN)

Class Library DataAccess
Namespace: SSW.Northwind.DataAccess
Folder: SSW\Northwind\DataAccess\
Folder: SSW\Northwind\DataAccess\Components
Folder: SSW\Northwind\DataAccess\UnitTests
Output: SSW.Northwind.DataAccess.dll

This project should contain all the code and SQL statements used to access data from your backend. This project can be code-generated

(REPLACE BY DOMAIN)

Class Library Tests
Namespace: SSW.Northwind.Domain.Tests
Folder: SSW\Northwind.Domain.Tests\
Output: SSW.Northwind.Domain.Tests.dll

Only need this project if you are not using reusable components and then you do not need Tests folders above

For more information on naming unit tests

Wise Setup Northwind
Folder: SSW\Northwind\Setup\
Output: SSWNorthwind_v1-11.exe

For Windows: Make an EXE in Wise instead of an MSI because it allows the application to be upgraded

For Web: Can be manual via an _Instructions.doc or a Setup.bat file

We have separated the unit tests, one for each project, for several reasons:

  • It provides a clear separation of concerns and allows each component to be individually tested
  • The different libraries can be used on other projects with confidence as there are a set of tests around them

For common library project, project name should include the company prefix and solution name, this is so other internal solution can include the common library's project. This will help debugging and development processes.

Project Type Project Name Note
Class Library Northwind.Common Business
Namespace: Northwind.Common.Business
Folder: ..\Northwind\Common\Business\
Output: Northwind.Common.Business.dll
No space in the Project Name

For project documents, we should also add them into solution for later reference, and different document types will be put in different folder, e.g. Mockup files will be in Northwind\Documents\Mockup\

Project Type Project Name Note
Documents Documents
Folder: Northwind\Documents\
This is outside the solution trunk
solutionlayout.png Figure: Good Example - The Solution and Projects are named consistently