You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Separate the database logic from the service layer to improve code modularity, maintainability, and facilitate testing.
Background:
Currently, our Express.js API directly performs database operations in the service layer. This intertwined structure can become a maintenance challenge and hinders the clarity and separability of concerns in our codebase.
Proposed Changes:
For each of the service layer modules, the following should be completed:
Introduce a Repository Layer
Create a new layer (Repository or DAO) specifically for handling raw database operations.
Define methods in the repository layer like findWithAggregation, findMatrixById, and findOneMatrixById.
Refactor Service Layer
The service layer should call the newly defined repository methods for database operations.
Retain business logic, such as handling transactions and complex computations, in the service layer.
Unit Testing
Adjust unit tests (if any) to align with the new structure.
Mock the repository methods when testing the service layer.
Update Controllers
Ensure controllers remain thin and only handle HTTP requests, input validation, and returning responses.
Overhaul Error Handling
Implement and use custom exception classes hosted by the app/exceptions module.
Objective:
Separate the database logic from the service layer to improve code modularity, maintainability, and facilitate testing.
Background:
Currently, our Express.js API directly performs database operations in the service layer. This intertwined structure can become a maintenance challenge and hinders the clarity and separability of concerns in our codebase.
Proposed Changes:
For each of the service layer modules, the following should be completed:
Introduce a Repository Layer
Refactor Service Layer
Unit Testing
Update Controllers
Overhaul Error Handling
app/exceptions
module.Tasks
develop
when all tasks are completed.matrices-service.js
+matrices-repository.js
as reference examples for refactoring.The text was updated successfully, but these errors were encountered: