Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats a recommended solution structure for a somewhat large website in asp.net

Im currently trying to refactor a project(asp.net mvc) that doesnt have any separation at all. just folders :s

  • The project has a bunch of EF Code First classes (People.cs, Exam.cs, Message.cs, etc)
  • The project has several repositories (which all use EF Data Context)
  • And of course a lot of controllers and viewmodels

We have a Tests Project but we arent very good at TDD so its not something we are really working on as of now.

I would like to have a clearer separation on the different responsibilities that the project has to address and would appreciate some advice on a good project structure that achieves this.

Please help. thanks in advance

like image 798
nacho10f Avatar asked Jul 28 '11 20:07

nacho10f


2 Answers

I would suggest following a Domain Driven Design (DDD) and one suggested way of laying this out would be creating the following projects:

Company.Project.Web <-- Your MVC Application, though you can still use WebForms Company.Project.Domain <-- Data Transfer Objects (DTO's), ViewModels, Business Logic, Events Company.Project.Data <-- Repository Interfaces

Company.Project.Data.EF <-- EntityFramework Specific Implementation of Repositories Company.Project.Model <-- Your EF CodeFirst Classes

Company.Common <-- A common project of utilities and/or extensions

I would suggest you take a look at Project Silk http://silk.codeplex.com/ from the patterns and practices team. Great reference implementation of DDD, Repository, and MVC as well as mixing in HTML 5 and jQuery (vNext).

like image 118
jdmonty Avatar answered Oct 05 '22 23:10

jdmonty


We use a similar design to that mentioned by jdmonty but a bit simpler. We do the following:

  • ApplicationName.Web - MVC Application
  • ApplicationName.Services - Business logic
  • ApplicationName.Domain - EF CodeFirst classes and the repositories that act on them
  • ApplicationName.Common - Classes and utilities used by multiple projects
  • ApplicationName.Tests - Test for the various projects

The Web project is dependent upon the Services project. The Services project is dependent upon the Domain project.

like image 20
Nick Olsen Avatar answered Oct 06 '22 00:10

Nick Olsen