-
Microservices make it possible to update and run individual functions. For example, a user management system or a payment processing module without affecting other parts of the application.
-
To build a working microservice architecture, you need to clearly define module boundaries. In the context of microservice boundary quality, there are three main concepts: 1.
-
Coupling is a measure of how interdependent different subroutines or modules are.
-
In other words, the way and degree of interdependence between software modules within a given IT architecture.
-
Coupling can be strong (high coupling) or weak (low/loose coupling).
-
High coupling means a high degree of dependence between modules, which makes them harder to understand, change, and test.
-
It is perceived as a serious system drawback and is also one of the characteristic properties of monolithic systems.
-
Low coupling is a system state in which changes in one module do not require changes in another.
-
A loosely coupled service has only the minimum necessary knowledge about the services it works with and is responsible only for its own data in the shared context.
-
A loosely coupled service has three main properties:
-
A small number of dependencies between subsystems (modules)
-
A low dependency of one module on changes in another module.
-
Ease of reusing subsystems. 2.
-
Cohesion is the degree of relatedness among elements within a module, that is, how closely the tasks performed by a software module are connected.
-
As with coupling, there are two levels of cohesion:
-
High cohesion is a state in which the responsibilities of components within one module are well aligned and the module does not perform an excessive amount of work. Unlike strong coupling, which concerns relationships between different modules, high cohesion within a single module is a positive sign.
-
Low cohesion is a state in which one module performs many disparate functions or unrelated responsibilities.
-
This module property leads to the following problems:
-
Difficult to reuse
-
Maintenance complexity, unreliability, constant susceptibility to change
-
The concepts of coupling and cohesion are closely intertwined.
-
Coupling describes relationships between objects across module boundaries.
-
Cohesion applies to the relationships between functional elements within a module's boundaries.
-
It is important not to confuse these two concepts. In this article, we focus on coupling as an indicator of a flexible IT architecture.
-
The ideal setup is a combination of loose coupling between service modules and strong cohesion between the components inside a module.
-
That is, when a module has a small number of external links and is responsible for solving related tasks. 3.
-
Encapsulation is hiding implementation details inside a microservice.
-
These details are, in a sense, placed in a capsule so they cannot be damaged from the outside.
-
The idea is to use only the data that is available and not dig into the internals.
-
In other words, a service should know the minimum possible context and data about the other service it communicates with, and it should use only what is available by default. For example,
-
David Parnas, a Canadian computer scientist and one of the creators of the software modularity concept, viewed the links between services as the assumptions they make about one another.
-
The fewer such assumptions there are, the easier it is to change one part of the service without affecting another.
-
Reducing the number of links and the amount of information services share with one another makes development faster and the service more transparent and flexible.