Are the MVC paradigms and Webforms (with code-Behind) mutually exclusive?

Asked

Viewed 163 times

0

My doubt stems from an instructor’s explanation that the MVC standard would apply to the presentation layer, but upon encountering this other question and answers I started to believe that either the Model-View-Control layers or the Web-BLL-DAL layers are chosen with the Model layer (or DTO) making a link between them.

  • Did the answer solve your problem? Do you think you can accept it now? See [tour] to understand how it works. It would be helpful to indicate to everyone that the solution was useful and satisfactory for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

2

MVC and Webforms are design patterns or architectural patterns as they consider some (there are controversies), but they are not paradigms.

3 Layers have nothing to do with it. It’s too generic to define anything. It is possible to apply these three specific layers shown in the question referenced with MVC, with Webforms and with numerous other forms. That’s orthogonal. But it doesn’t make sense.

In thesis it is possible to use MVC and Webforms together. It doesn’t make much sense, it would only occur in a legacy system that is transitioning to the other pattern. Or the programmer has no idea what he’s doing. It’s not very easy to make it work right, but it’s possible. In essence there will be an integration between the parties more than being one thing. Technically they are not exclusionary, but in practice they end up being.

The referenced question and answer shows that DAL and BLL are usually mixed in MVC. E Controller and View are strongly integrated into Webforms (well, this doesn’t show so clearly, but it is so).

In MVC the business rules are in Model. If someone separates their data structure and the rules will be creating two layers for the Model. Some people defend it, some people find it abominable.

The Controller handles the application flow. Some people consider that enforcement rules that go beyond the flow should be separated into another layer of service. Others find it abhorrent. Some people put business rules here. Some people find it very strange.

To View MVC works much more uncoupled than the equivalent of Webforms. In the latter it is possible to find rules of application and even business (via code-Behind), especially when the programmer is lost.

For everything there are advantages and disadvantages. Whoever follows a fixed rule and says "this may or may not", has already started wrong. There are some things that are rarely advantageous, of course, but you have to understand in depth what you are doing, the consequences of all decisions, so the decision will be more correct, which is the only thing that matters. Meeting rules imposed by third parties does not help at all.

Remember that Webforms is totally legacy, and even Classic ASP.NET should no longer be used in new projects, go to ASP.NET Core.

Browser other questions tagged

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