Getting started – Project Structure

I have a standard project structure that I work to on 90% of all MVC.net web applications that I develop and would like to give some insight to what each part of the application

Folder Structure

The image below is the file system folder structure of this project.

  • Build
    Contains the build scripts for the CI server
     
  • Lib
    Contains all of the third party assemblies that will be used in this application.
     
  • Licenses
    Contains all of the third party assembly licences.
     
  • Src
    Contains the source code and project files.
     
  • Tools
    Contains the tools required for building and testing the application such as Nant and Nunit.

 

Visual Studio Solution

The image on the right is of my Visual Studio solution explorer which contains the following projects:

  • Build
    I create a Solution Folder and attach the build script files for easy access to edit within visual studio.
     
  • Core
    Initially when I create a new project, I keep all of my application and domain code in a core project separating the layers by namespaces as I personally do not see the need to overly complicate a project structure until such time as the codebase grows large enough to justify separating out to codebase into individual projects.
     
  • Core.Specifications
    Core.Specifications is referenced by Core.Specifications.Integration and Core.Specifications.State.  Core.Specifications is where I keep all of my test setup/helper classes.
     
  • Core.Specifications.Integration
    When it comes to testing an application, I prefer to separate out my integration and state based tests into separate projects.  It enables me to easily differentiate between the slower integration tests and fast state based tests when setting up my continuous integration server.

    The integration tests are those which actually execute against databases or other live services.
     
  • Core.Specifications.State
    The state based tests are those which are only testing the current “state” of the class under test.  For example when I add a Page to a Section, I want to assert that the page has actually been added to the sections page collection.
     
  • UI
    The UI project is the presentation layer of the application.  Harnessing the MVC framework and the Spark view engine give so much more freedom than the ASP.net Web Forms model.  It also has major benefits over the default MVC.net view engine, such as the formatting of the views – no classic asp spaghetti code in sight!
     

Next post will be on configuring the projects prerequisites - setting up castle/nhibernate/test helper libraries/MVC/Spark etc etc...

The Ninja

p.s the next post will be up when I return from Hong Kong (January)