What are the layers of a web application?

Asked

Viewed 1,905 times

3

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

Presentation Layer

Windows Forms, GUI (User interface windows).

Layer of Business Rule

Classes written to define the business rule.

Layer of Data Access.

Classes written to perform database operations (CRUD).

  • And in web development how this division of layers works ?

Obs : Examples will be welcome.

  • 3

    I don’t know what it is, but it looks like you just answered yourself.

  • No guy type in web development we have files and a different structure in the project, and this I want to know , thinking that I could not express very well rs.

  • I don’t know if I understood it very well, but in the Web model we have the same layers, the difference is the presentation layer, which will be web (html, for example). So much so that you can (I don’t say you should or shouldn’t, but you can) use the business layer and the Data Access layer you use on your Winforms system.

  • 1

    I would say that this question is too broad, not least because the architectural model that the answers need to be based on is not defined, so the division of layers can be on top of anything. It would be nice to limit the question further.

  • @Ciganomorrisonmendez I’m working on this I intend to reformulate the question , I’m giving a read on the concepts before , but I do not think I could express right not ><.

3 answers

6


You said yourself that you model GUI this way. It’s your form, not everyone’s, not the most suitable for all applications. There are those who prefer to have fewer layers, there are those who prefer to have more and there are those who prefer to have other layers or at least not consider everything as a layer. Where to treat things can vary.

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

Nowadays it is quite common to use the pattern MVC for web. Something that can be used for GUI too and is very similar to the one described. There is a comparison on this site. There’s even variations of how MVC is applied.

Have specific question on the subject to ASP.NET and to PHP. I am not validating that the answers contained there are definitive on the subject, let alone disqualifying. There is also a general definition of the standard.

There are questions on how to use each part of the MVC as if the controller it is necessary. There’s always controversies of what goes where. What you can use in each "layer".

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

There are controversies about the use of DAL or DAO, BLL, on the use of the standard Repository, or how it should be used with other specific techniques, among other things. Or how to modularize in general.

There are those who opt for MVC because everyone is doing it. It is not always necessary to work that way. In PHP pragmatists continue to do it without a model and a controller clearly defined. Often it does not even separate exactly the vision. The problem only occurs when the person uses a pattern where everything is together without knowing why or by laziness. If one can adequately justify, one does not need layers in most applications, at least not in this way.

1

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

The presentation layer would be the View.

The business rule is MOdel (Business Model, Business Logic).

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

The CMVC controller is the mechanism that connects the Model and View layers.

For examples and more details, see this topic: /a/116422/4793

0

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

Something I don’t like in the term 3 camadas, is that I never know if you’re referring to 3-layer or 3-tier, our Igua ends up creating a confusion between these two architectures.

Anyway, I hope you don’t confuse MVC with 3-layer, although it is possible to make a relationship between Model -> Presentation, Controller -> Business and Model -> Data Access.

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

for example, we may have an application made in MVC with only 2 layers, where we build our Apresentação and Regras de Negocio within the 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 of Controller and implement them elsewhere, for example in a WebService, in this case we have three layers.

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

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

In any case, not always MVC is 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 the tiers (2, 3 ou n), after all the system being scalable is not always the most important.

Browser other questions tagged

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