DEV Community

Cristovão Farias
Cristovão Farias

Posted on

The joy of the Service pattern and Dependency inversion

I believe that every Dev has come across the situation of needing to do something and having to look for something ready to solve their problem, such as libs and database packages, external services that seek to facilitate our day-to-day lives as developers.
Eventually the Dev will come across an update that breaks the current code to use a new implementation or etc. For small projects, this doesn't have such an impact, but for large projects, it can cost you your job or hours of time updating and hoping that something doesn't break in the process.

For this we have a Project Pattern and a rule that helps a lot, they are the Service pattern and the Depency inversion of solid, together they help us to make a structure that allows us to scale the system and not depend on packages or external changes, only ours.

I don't intend to put the whole pattern here to encourage you to study it, but believe me, it's very worthwhile. My recommendation is always Uncle Bob's book and the refactoring guru's website. Finally, studying solid will help you understand more about it.

Site mentioned:
https://refactoring.guru/

Top comments (0)