Ultimate Visual Studio Solution Structure

Understanding that this may be subjective based on the project, I am looking for a “best practice” method for structuring a VS (Visual Studio) solution.

Please feel free to edit this, comment on what you think might be wrong, suggest alternatives, etc. I would really like this Community Wiki to become a great resource for people starting with VS Solutions.

Below I am working for me now (in my current project), however I know that there is something in the wrong place. In my scenario, I am building a web application using MVC 2

Please post your understanding of the structure of the final decision so that we can get an idea of ​​the “best way” / “best practice” (whatever that says)

IE:
How do you split your DAL (Data-Access-Layer) / BLL (Business-Logic-Layer)?
Do you put your repository layer and service level inside your BLL? If you use MVC (Model-View-Controller), do you save your controllers in the user interface instead of Core?
Do you drop a lot of things into your Utility / Miscellaneous folders, or can you split it even further?
etc...




  • Mysolution
    • MySolution.Core
      • Authentication
        • this is where i have POCO and a method for testing poco in the userData section of the auth cookie.
      • Base
        • here i keep my BaseController and BaseGlobal
      • Controllers
        • all my controllers (obviously)
      • Domain
        • DatabaseModels
          • contains the L2S.dbml file
        • Jsonmodels
          • models used to pass JSON objects to veiw
        • Storage facilities
        • Services
        • ViewModels
      • Extensions
        • all extension methods
      • Filters
        • Action filters
      • Utilities
        • Apis
          • all third-party API code is used here.
        • Badges
          • icon calculation goes here.
        • Mailclient
          • send plain text or html email using classes here
        • RoutingHelpers
          • contains a class to include lowercase routes
        • also contains things that I don’t know where else to put ... IE: HTMLSanitizer, custom HtmlHelpers, UserInfo helper (IP address, browser, etc.), DataConverter, etc.
    • MySolution.UI
      • App_browsers
      • Assets
        • Css
        • Images
        • Scripts
      • Kinds
      • Global.asax - inherits from BaseGlobal
      • Web.config



Screen shots
CoreUI

Please feel free to comment accordingly, or better yet, post your own version (answer) below. I know that I have not the best way.

+44
visual-studio projects-and-solutions
Aug 18 '10 at 20:19
source share
3 answers

Your project decision / structure looks pretty good to me. If you have never looked at S # arp Architecture , you might want to. The main difference between your structure and S # arp architecture is that S # arp splits controllers, services, and repositories into separate projects. The main advantage of this is that it makes it easier to apply the boundaries of your dependencies (for example, you will not accidentally access specific libraries for accessing data from code in Core).

In addition, your structure looks very similar to the one that I usually use for my projects. I also add the Extensions folder for extension methods, as it is sometimes difficult to find a suitable location for.

+7
Aug 18 2018-10-18T00:
source share

Nice Wiki.

I am starting a new project, and this is the structure I started with.

This follows from Microsoft best practices (business, data, services, presentation).

alt text

In my solution:

  • Business: domain / project-specific logic, and above all, POCO.
  • Data: repositories. self explanatory.
  • Services: logic on top of repositories. I can add caching, filtering, etc. here My user interface communicates with the repository through services, and not directly to the repository. (one-to-one dependency for the user interface).
  • Presentation: MVC Application (TBD).

You will notice that I also have the habit of prefixing the project assembly name using FQN.

I just like its appearance, plus in Object Explorer everything looks beautiful and "looks like a tree."

I also have the habit of putting a number in front of a folder, so it is sorted according to "what need what". In other words, it all depends on the business level (therefore, it is on top), the repository depends only on the business, the services depend on the repository and business, the presentation depends on the services and business, etc.

Of course, the above is the starting point. All I have now is a repository that returns users and services that apply logic on top of it (filtering).

In the end, I will have more business projects, more repositories (one for each logical area of ​​the web application), more services (external APIs, integration), and, of course, I have nothing in the presentation (im doing TDD).

I also like to have dependencies in one place (project folder).

For extensions, I have one class (Extensions.cs) for each project. In other words, I am Extending the repository or Extending the user service or Extending some user interface features.

For test projects - I have a project project for a draft solution.

What are my two cents (what it costs).

+10
Sep 15 '10 at 2:07
source share

There are opportunities for improvement.

There are 4 main parts to any of my decisions. User Interface Layer, Business Layer, Data Access Layer, and Utilities. Each part is a project.

My ultimate goal is NEVER to write code in one place, but for reuse.

The user interface and data access are obvious.

Everything related to the project I'm working on is part of a business project.

Utilities are what I call a shared library. These are good helper functions that I can use in many projects. For example, a feature that helps keep a journal.

+7
Aug 18 '10 at 22:01
source share



All Articles