dtvala2930 / BE

https://operor-vert.vercel.app
0 stars 0 forks source link

[Chore] The main service is handling too many responsibilities #7

Open malparty opened 3 months ago

malparty commented 3 months ago

Issue

The controller BE/src/modules/search/search.controller.ts and the service BE/src/modules/search/search.service.ts are handling too many responsibilities:

Controller:

Service

This has impacts on the maintainability, readability, and testability of the code.

Expected

The code is expected to follow the Single Responsibility Principle as much as possible.

For example, if the service has both the Google HTTP request and the HTML parsing, it makes it much harder to write tests for the HTML parsing (because you will have to mock the tool used for HTTP requests). And if you need to change the tool for HTTP requests later, you will have to re-write your HTML parsing tests.

Using two separate classes (or functions) allows for a better separation of concerns.

dtvala2930 commented 3 months ago

Done