MVC in C#, separate by folders or class library?

Asked

Viewed 153 times

1

I saw some examples that separate by folders, and others that separate by a class library and then create the note in the references. Both forms can be used?

  • 1

    There are some patterns, such as the famous "N-Tier Layer" (Multi-layer Application) and the Domain-Driven Design http://www.eduardopires.net.br/2014/10/tutorial-asp-net-mvc-5-ddd-ef-automapper-ioc-dicas-e-tricks/, I recommend you to study object orientation (OO) and SOLID http://www.eduardopires.net.br/2013/04/orientacao-objeto-solid/

  • Hello Jean, in the question I didn’t want to ask about which design-Pattern is best. But about the difference, in C# MVC, separate the model view... By folders, or create a class library and make the appointment in the references.

  • 2

    Viewmodel... if you are going to use only in a MVC project, I see no problem being in the same namespace of the web application... now if you are going to use them in a web application and a web api (for example), it would not make sense to be in a common library for both?

1 answer

1

both can be used yes, but both have meanings in their use.

I usually sort by libraries the resources that are and can be accessible by other applications, not just MVC, for example if creating an application that consumes common classes, such as database entities, would be interesting to separatelas and keep the common resource among them in another location (DLL for example).

Already this question of folders I separate by folders my projects for grouping and separation of the layers of my application as a whole, example the layer responsible for the data, for the presentation of the application to the end user, for the different services if any, etc.

I hope I’ve helped! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.