Design & Iterate the Monolithic architecture
In the previous article we have seen the monolithic architecture in single codebase.
Now we are going to design and iterate the monolithic architecture of single codebase.
Here the initially the application has single codebase (Client, Server, Application & Database), Now we divide the codebase into multiple parts, so that application becomes more manageable and many more advantages.
Now, add a separate Database from codebase in one iteration and in the next iteration we divide the single codebase into Client, Server and Database (here we are using RDMS for maintaining consistency data).
Benefits of separation of codebase:
Easy Development.
East Debug and Test.
Easy to Deploy.
Now the code become too complex overtime.
Problems:
Become Complex over time.
Hard to understand code.
Need Code organization.
Now we are going to solve the above problems:
The solutions are:
Separate the UI, Business and Data related codebase (Layered Architecture).
Layers as a logical layers.
Layered Architecture.
Using SOLID Design principle.
Separation of code into multiple layers of code is called Layered (N-Layered Architecture)
The layered architecture pattern is the most commonly used architecture pattern. Known as the N-Tier architecture style or Multi-layered architecture.
Organize the components of an application with similar functionalities into horizontal logical layers. Each layer performs a specific role within the application.
Still using monolithic architecture separating horizontal logical layers, components are interconnected but don't depend on each other.
Organize the code for separation of concerns.
Layers of isolation that layers can be modified and the changes in layers it won't affect the other layers.
Components of Layered Architecture
Presentation Layer
It is responsible for user interactions with the software system.
Application layer/ Business Layer
It handles the different aspects related to functionality requirements including use case implementations.
Database layer
It is responsible for handling data, databases such as a SQL database.
Now, while implementing the code we have to fallow some principles with that our code can be modularity and manageable and etc..,
The most important Design principles are:
Separation of Concerns (SoC) Design principle.
SOLID Design Principle.
Separation of Concerns (SoC) Design principle:
Separation of concerns(SoC) is one of the core software design principle.
Separation of concerns is a design principle for separating computer program into multiple distinct sections.
Isolate the software application into separate sections, manages complexity by partitioning the software system.
Distinguish between the concepts of layer and tiers with certain responsibilities.
Elements in the software should be unique.
Limits to allocate responsibilities to each separation of layer.
With this principle we can achieve the low coupling between the layers and becomes more high-cohesion.
SOLID Design Principle:
S - Single Responsibility
Each of your components or modules in your code should responsible only for one functionality.
O - Open-Closed principle
When we design the system, it should able to extend without changing the existing architecture.
L- Liskov Substitution Principle
Systems can be substitute each other easily, In our case we can use plug-in services that we can shift them easily.
I - Interface Segregation Principle
It states that no code should be forced to depend on methods it doesn't use.
D- Dependency Inversion Principle
States that high-level modules should be depend on low-level modules, both should be depend on the abstractions.
Now the single codebase system becomes in multiple layers of code it becomes more
manageable.
Now the codebase (application architecture) looks like below.
Now we will see the architecture with real world technologies in Java world .NET world.
Now we can evaluate the our Layered monolithic Architecture.
Benefits of Layered Architecture:
Easy development, Debug and Deploy the application.
Our code fallows the design principles such Separation of Concerns(SoC) and SOLID Design principle. The code becomes more manageable.
Drawbacks of Layered Architecture:
The layers are dependent on each other.
Highly coupling each other.
Hard to maintenance.
Complexity of codebase.
Hard to change libraries i.e., change ORM tool with different library requires to modify the business layer.
Solutions for the Drawbacks:
The clean architecture.
In the clean architecture we will fallow the The dependency rule.
We dive into Clean architecture in the next blog.
Thanks for reading...