Today's Question:  What weekend projects have you created?        GIVE A SHOUT

Technical Article => Programming =>  Java

Benefits and Drawback of a Layered Architecture

  techhsprout      2017-05-04 08:19:34      4,239    0

Most enterprises today are application centric. But the problem with the application is that their database schemas, user interfaces, programming interfaces and object models are tightly coupled and difficult to change. If you want to add a new field to a database table and you’re lucky, the change will reflect through the entire system. But often the change needs to be replicated manually across the entire system. And as applications are difficult to change, adding business rules or process to the application does not facilitate business agility. This is where layered architecture comes into play. 

What Is Layered Architecture?

Also known as the n-tier architecture, the layered architecture is a de facto standard for most Java EE (Enterprise Edition) applications. It is widely adopted and used by software architects, designers, and developers. The layered architecture pattern closely matches the conventional IT communication and organizational structures found in most businesses. The structure is divided into four important categories: presentation, application, domain, and infrastructure. Each of these layers consist objects specific to a particular concern it represents.

  • Presentation layer: This layer consists all the classes responsible for presenting the user interface to the end user or sending the response back to the client.
  • Application layer: This layer consists all the logic that an application requires to meet its functional requirements while not being a part of the domain rules. In most systems, the application layer also contains services orchestrating the domain objects to fulfill a particular use case scenario.
  • Domain layer: This layer represents the underlying domain that mostly contains domain entities and in some specific cases, services. Business rules such as algorithms and invariants should all be a part of the domain layer.
  • Infrastructure layer: Also known as a persistence layer, the infrastructure layer includes all the classes responsible for performing the technical actions such as persisting data in the database, like repositories, DAOs (data access objects), etc.

Benefits of Layered Architecture:

  1. Simplicity: The concept of layered architecture is easy to learn and implement.
  2. Consistency: The layers along with the overall code organization is consistent across all the layered projects.
  3. Browsability: All the objects are kept together. So, when you need to change something in some or all the objects of a particular type, it is easier to quickly find an object.

Drawbacks of a Layered Architecture:

  1. Lack of inbuilt scalability: The principles of layered architecture hinders the growth of your project as it does not help to scale your project. You are required to find a key to organize it on your own.
  2. Hidden use cases: It is difficult to determine the use cases of your project by simply checking the code organization. You need to refer the class names and in most cases, implementation.
  3. No dependency inversion: In a layered architecture, the dependencies are direct and conceptually changes into essential higher layers from a low-level infrastructure layer.

In conclusion, a layered architecture is all about organizing code for separating concerns. Are you planning to implement layered architecture while leveraging Java enterprise development? Let us know your thoughts in the comments below.

Author Bio

I am Rini, am digital marketing evangelist and technical content writer. I write about latest web and mobile technologies and expertise on CMS and CRM as I am associated with Rishabh Software. My main objective is to keep my technical reader updated with latest news and technology. Apart from my busy schedule, I enjoy adventure sport. I am a pet lover and like long trip on short notice.


Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr 



No comment for this article.


Load balancing

By sonic0002