What I’ve Learned About WebAPIS, Layered Architecture

Abderahmane Toumi
4 min readNov 1, 2021

In this post, I’d like to discuss layered architecture in the context of software engineering. Why?? because layered architecture was the first topic I came across when exploring how to develop and design the architecture of a web API.

So even though, at first, I assumed web APIs were just software, but after doing some research, I found that web APIs are complete products with a full Lifecycle, this life cycle differs from one vendor/expert to another.

During my research i first came through this concept of layered architecture in Martin Fowler Website in his blog post about LayeringPrinciples he wrote this post after a workshop that he attended, in this workshop participant came up with a set of 14 design principles of layered architecture, Matthew Renze in his blog post visualized these principles in a colored table as we can see below:

A visualization of Flower’s Layering principles by Matthew Renze. source

It is important to keep in mind that Flower stated why we should not read too deeply into this list because it contains some overlaps and imprecision, i tried to learn more about the various items on this list, for eg, i found that the last item in this lists which has the most downvotes separate development teams by layer , is a bad practice in managing teams, as an example and a proof we can take what Dave Farely said about structuring a remote development team by the role of its members, which we can say that it includes or is similar to the principle we mentioned earlier, he also described it as an antipattern on a youtube video he published in his channel Continuous Delivery the title of the video was How To Manage Remote Development Teams.

What is Layered Architecture :

layered architecture is a software architecture pattern, it is also called n tier architecture pattern according to Mark Richards in his book Software Architecture Patterns, This pattern was one of the first architectural styles and is still widely used in enterprise applications today.

The various layers and components in this pattern are organized horizontally, with each layer having a distinct role and responsibility, as an example of a layered architecture we can take this diagram as an example :

layered architecture example from The Reformed Programmer Blog

a system built based on the layered architecture where each layer can be marked as closed or an open layer.

closed layer: If a request goes from one layer to another, it cannot ignore the layer between them if it is marked as closed.

open layer: meaning that if there is an open layer between two layers, the open layer can be ignored if it is between them.

you can read chapter 01 of the book Software Architecture Patterns for more details.

Problems with layered Architecture :

First, Layered architecture is a basic, popular, and strong architectural approach that is utilized in the majority of application design. but there is a problem in how to effectively evaluate this architecture, This is due to the freedom afforded to each developer and architect to make selections based on his or this situation.

Second, occurs when requests pass through numerous levels without being subjected to any type of treatment or reasoning, this is an antipattern called architecture sinkhole.

Third, that this architecture is hard to deploy as mentioned in Software Architecture Patterns “it tends to lend itself toward monolithic applications”, it has also some other cases where this pattern causes problems in terms of reliability, performance, and scalability.

Fourth, Juha Savolainen and Varvana Myllärniemi in Layered Architecture Revisited — Comparison of Research and Practice they compared layered architecture notion in both the academic and industrial era, their conclusion and findings were that layered architecture usage is more complicated than what has been described in the literature and that there is a lack of layered architecture study in the academic era.

A solution to identify some Layered Architecture problems :

recent research published on June 8, 2021, Sanjay Thakare, Arvind W Kiwelekar, and Babasaheb Ambedkar in their scientifique paper Redefining measures of Layered Architecture, tried to redefine the measures of layered architecture based on the relationship between the software components using the following metrics back calls, skip calls, and cyclic structures., they also introduced a measure to define the logical separation amongst the layers.

References

1- Layered Architecture Revisited — Comparison of Research and Practice

2- Redefining measures of Layered Architecture

3- Architecture of Business Layer working with Entity Framework

4- LayeringPrinciples

5- Chapter 1 of Software Architecture Patterns

--

--

No responses yet