What are the layers of a web application? [closed]

3

In a simple desktop application in C# Windows Forms for example and layered model can be defined as follows:

Presentation Layer

Windows Forms, GUI (Windows for user interface).

Business Rule Layer

Written classes to define the business rule.

Data Access Layer.

Written classes to perform operations with the database (CRUD).

  • And in web development how does this division of layers work?

Note: Examples are welcome.

    
asked by anonymous 08.04.2016 / 16:46

3 answers

5

You yourself said that you model GUI that way. It's your way. Not everyone's, not the most suitable for all applications. Some people prefer to have fewer layers, some people prefer to have more. There are those who prefer to have other layers or at least not consider everything as layer. Where to treat each thing can vary .

For web you can do the same. Use the same template or create / use another .

Nowadays it's quite common to use MVC for web default. Something that can be used for GUI too and is very similar to the one described. There's a comparison about this here on the site . You have up to variations of how MVC is applied .

You have a specific question about the subject for ASP.Net and for PHP . I am not validating that the answers contained therein are definitive on the subject, much less disqualifying. You also have a general default setting .

There are questions about how to use each part of the MVC as if the controller is needed >. There's always controversies of what goes where . What you can use on each "layer" .

There are differences if the page will be rendered on the client or on the server.

There are controversies about using the DAL or DAO , BLL , about using the default Repository , or < a href="https://en.stackoverflow.com/q/51536/101"> how it should be used with other specific techniques , among other things. Or how to modularize in general.

There are those who choose MVC because everyone else is doing it. It is not always necessary to work in this way. In PHP the pragmatists continue to do so without a template and a controller . It often does not even separate the vision . The problem only occurs when the person uses a pattern where everything is together without knowing why or for laziness. If the person can justify properly, he does not need layers in most applications.

    
08.04.2016 / 17:14
1

It's basically the same. What you described above is the MVC. Model Control View.

The presentation layer would be V iew.

The business rule is the M odel (Business Model, Business logic).

The data access layer is the Data Access Object (DAO) and is part of the Model.

The C MVC ontrol is the mechanism that links the Model and View layers.

For examples and more details, see this topic: link

    
08.04.2016 / 17:00
0

I was writing the text below as a comment, but it ended up getting a bit long.

One thing I do not like about the term 3 camadas , is that I never know if you're referring to 3-layer or 3-tier , our language ends up creating a confusion between these two architectures.

In any case, I hope you do not confuse MVC with 3-layer , although it is possible to make a relation between Model -> Presentation , Controller -> Business and Model -> Data Access .

The default MVC is a Design Pattern used to make a logical separation of the user interface, whereas 3-layer is an Architecture.

For example, we can have an application made in MVC with only 2 layers, where we build our Apresentação and Regras de Negocio within MVC , in this scenario Apresentação and Regras de Negocio end up behaving like a single layer, but the Data Access layer is still isolated ( Banco de Dados ).

On the other hand, we can remove the Regras de Negocio from Controller and implement them elsewhere, for example in WebService , in this case we have three layers.

If you prefer you can move your Apresentação to the client, for example using SPA for example, and keep your Regras de Negocio to API RESTful

And finally we can create more layers, for example other layers of Apresentação ... Desktop , Aplicação Mobile , Web , etc ... split Regras de Negocios , for example Financeiro , Contabil , Operacional , etc ... and even the layer of Acesso a Dados ... NoSQL (eg: MongoDB ) and SQL (eg: SqlServer ).

In any case, MVC is not always the best for the project. in some projects 2-layers is more than enough, in others it may be necessary to use n-layers , the same goes for tiers (2, 3 ou n) , after all the system is scalable is not always the most important.     

11.04.2016 / 15:14