Best practice for structuring the new big ASP.NET MVC2 plus EF4 VS2010 solution?

we are creating a new web application using Microsoft ASP.NET MVC2 and Entity Framework 4. Although I am sure that there is no one correct answer to my question, we are struggling to agree on the structure of the VS2010 solution.

The application will use SQL Server 2008 with a possible future version of the Azure cloud. We use EF4 with TOC POCOs (model first) and access several third-party web services. We will also be connecting to several external messaging systems. The user interface is based on standard ASP.NET (MVC) with jQuery. In the future we can provide a version of Silverlight / WPF, as well as a mobile one.

So, just, we start with a clean VS2010 solution - then what? I suggested 4 data folders (EF edmx file, etc.), Domain (entities, repositories), services (access to web services), presentation (web ui, etc.). However, in the “Presentation” section, creating an ASP.NET MVC2 project explicitly creates its own “Models” folder, etc., And it does not seem to be too good for this proposed structure. I also skip the business layer (or is it sitting in a domain?).

Again, I am sure that there is not a single correct way for this, but I would really appreciate your views on this.

thanks

+4
source share
5 answers

Jfar is true. At the moment, it does not matter what the structure of your decision is. You will have enough time to rearrange the solution later. I have made many small MVC applications and one large one, and I am still developing how I prefer to structure projects / solutions.

In terms of structuring and the MVC project, the only folder that really matters is Views. I began to tear myself away from the folder structure / Controllers and / ViewModels and grouping things by domain concept. If Student is one of your domain concepts, I will have the Students folder in the domain project, in the MVC Views folder, in the services project, etc. All domain classes, view models, controllers, etc. Will be held under the same folder name (in different projects). This way, you always know where to go if you want to change the code associated with the student.

In addition, we have a web project that hosts views and a separate class library project containing controllers. Most of my solutions have 12-30 projects.

+2
source

I believe that you are considering the project structure (and namespace) correctly at this early stage. Although the jfar dot is well designed, how often are you given the luxury to restructure your projects and namespaces before your first release? Even something that you offer is better than throwing everything into one project - right?

+1
source

You need to add - it is not so important how you organize your folders / solution, it is important how you organize your code .

So. If your application does not overlap correctly using fancy methods such as dependency inversion, is not neat and testable - it doesn’t matter if you put the smelly code in one or one hundred folders. You cannot switch from sql to Azure, from mvc to silverlight.

+1
source

What makes sense for you and your team?

Which folder in which the code is located does not mean anything (besides creating a small namespace) and can be easily changed by dragging and dropping.

At present, the organization hardly matters; you have so few files that you can easily browse around the slution. After your 6 months, and you have 1000 files when you need to think about organization.

With my personal projects, I dump everything into one project, at work I have 17 design solutions and 50 folders. A code is a code.

0
source

You can watch this video by Rob Conery for the idea of ​​structuring your MVC project: http://blog.wekeroad.com/2010/04/19/tekpub-starter

http://tekpub.com/production/starter

NTN

0
source

Source: https://habr.com/ru/post/1310141/


All Articles