loading...
Cover image for Services and SOLID

Services and SOLID

lebarreto profile image Letícia Barreto ・2 min read

Why do I need to use services?

Microservices are an architectural approach based on building an application as a collection of small services.
The service will store the business rule of your application, that is, everything that is very specific within your application.

What is SOLID?

SOLID stand for:

  • S - Single responsibility principle
  • O - Open closed principle
  • L - Liskov substitution principle
  • I - Interface segregation principle
  • D - Dependency Inversion principle
🚀Single responsibility principle:

Principle of Single Responsibility ⇒ A class must have one, and only one, reason for changing.

🚀Open/closed principle

Open / Closed Principle ⇒ You must be able to extend a class's behavior without having to modify it.

🚀Liskov substitution principle

Liskov substitution principle ⇒ Derived classes must be substitutable for their base classes.

🚀Interface segregation principle

Principle of interface segregation ⇒ Many specific interfaces are better than a single general interface.

🚀Dependency inversion principle

Dependency inversion principle ⇒ Depend on abstractions, not implementations.

By applying the principles we gain object-oriented benefits for our application, such as:

  1. Easy maintenance, understanding and organization;
  2. Open architecture to receive updates, improvements and new features without collateral damage
  3. Application of tests in an easy and simple way
  4. Easy code reuse
  5. Easy adaptation to changes in the scope of the project

Not using SOLID means exposing your application to problems such as:

  1. Code repetition, that is, a simple change must be replicated in several different points of its application
  2. Code without cohesive or standardized structure
  3. Rigidity and fragility, that is, any change causes a cascade of operations or failures in various parts of the system
  4. Difficulty performing and creating tests
  5. No reuse, that is, no or almost no functionality can be reused for other systems

Posted on Apr 28 by:

lebarreto profile

Letícia Barreto

@lebarreto

Passionate about web and mobile development technologies.

Discussion

markdown guide