worklenz icon indicating copy to clipboard operation
worklenz copied to clipboard

refactor: home page controller code cleanup

Open Nadeera3784 opened this issue 9 months ago • 2 comments

refactor: home-page-controller code clean up

Moved all the business logic to service layer for better separation of concerns and to enhance code reusability and testability. The following changes were made:

  • Tasks-related business logic has been moved to task.service.ts:

    • This includes methods for retrieving tasks, filtering tasks by group, and any other task-related operations.
    • The TaskService class encapsulates all task-related operations, making it easier to maintain and test.
  • Projects-related business logic has been moved to project.service.ts:

    • This includes methods for handling projects, such as creating, updating, and deleting projects.
    • The ProjectService class handles all project-related operations, ensuring a clear separation from controller logic.
  • Constants have been moved to constants.ts:

    • All hardcoded values and magic strings are now stored in a single constants file.
    • This improves code readability and makes it easier to manage and update these values.

Benefits of this refactor:

  • Reusability: Business logic in the service layer can be reused across different parts of the application.
  • Testability: With logic separated into services, we can write unit tests for these services without the need to spin up an entire server.
  • Maintainability: A clear separation of concerns makes the codebase easier to navigate and maintain. Changes to business logic can be made in the service layer without affecting the controller logic.
  • Scalability: As the application grows, new services can be added without complicating the controller layer.

Nadeera3784 avatar May 22 '24 00:05 Nadeera3784