Software Engineering Asked by keezar on December 28, 2020
Given a layered architecture consisting of
and a SPA web application communicating through REST endpoints with the backend (eg Angular and Spring), what would the presentation layer in such an application consist of? Would it only contain the stuff related to Angular? If so, what layer do the Spring rest controllers belong to?
When browsing the web, I realised that there seems to be some kind of ambiguity related to this topic. In most cases, the "presentation layer" is referred to as presentation in terms of visual presentation only, ie UI, which makes sense (at least somehow). In that case, the rest endpoints would belong to the business logic layer, which seems odd to me.
Maybe somebody can clear up my confusion.
Thanks.
There are different understandings of the presentation layer.
The traditional layered architecture that you describe predates the internet and in fact originates from the three tier architecture model. In this view:
The more recent MVP architecture is an adaptation of MVC that was triggered directly by the emergence of the internet. It sees it differently:
MVP is not mutually exclusive with layering: M is in general layered in order to distinguish the BLL and the DAL, but in this case there is an ambiguity about what the presentation really refers to.
You are therefore free to decide in which layer you want to see your REST API.
Personally if I’d use a classical layer scheme to describe my architecture, I’d prefer to be consistent and split it according to the three-tier decomposition.
But, if you consider your REST API to be part of the presentation, because it already presents the data in HTML, you’d not be wrong: you’d just analyse it according to an MVP decomposition of responsibilities. But I’d then advise to make a clean cut between the back-end and the front-end part of the P, and to ensure a clear separation of very different concerns.
Not related: another question is whether you want to continue to see the world in classical layers, or if you’d prefer a cleaner architecture
Answered by Christophe on December 28, 2020
A presentation layer is a presentation layer regardless of how the rest of your app is built.
You mention single page web apps (spa), rest, angular, spring, n-tier, etc. but a presentation layers job is still the same: combine data with a way to consume it.
That might be visual, auditory, or even tactile. It might be a GUI, a console, printed paper, plotter, web, an audio speaker, IP socket, or a fireworks display.
Each of those has needs that don’t need to be represented in the model. The presentation layers job is to transform data from the model into something that meets those needs.
Thanks to having a presentation layer the model can be free of knowledge of how data is presented. Ideally the same model can be presented many ways.
Presentation differences can be more than media. Key value pairs can be converted to graphical displays showing named positions on a map. Both forms could be presented to a GUI, a print out, or even a console (with a little ascii art).
The back end tech doesn’t change any of this. It does make some forms easier than others but the basic idea remains the same.
Answered by candied_orange on December 28, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP