I am trying to design an application that will be a REST API following MVC. For now ,I have 2 main features: Projects and Tickets associated to Projects.
I would like to apply SOLID principles, and I want to have a rough idea on how to design it, before I start coding.
My idea so far has been like this to create the Controller -> Service -> Repository
This means for Project
:
ProjectController -> ProjectService -> ProjectRepository
This may lead to methods such as:
getProject()
getProjects()
createProject()
updateProject()
deleteProject()
getProjectConfiguration()
Likewise, for Ticket
I would have:
TicketController -> TicketService -> TicketRepository
This may lead to methods such as:
getTicket()
getTickets()
createTicket()
updateTicket()
deleteTicket()
Each of them are likely to be extended in the future. Maybe just updating a certain part of the Project
or Ticket
, so a new endpoint would be added and therefore new methods.
How can I adapt this design to Single Responsibility Principle ?
This principle states each class should do one thing and be changed for one thing. But I don't know the level of abstraction of such thing.
Should I create a class for whatever involves the creation in Project
, another for whatever involves updating in a Project
and the same for deleting and retrieving, and the same for Ticket
?
Something like:
ProjectCreationXXX
, ProjectUpdateXXX
, ProjectRetrievalXXX
, etc etc etc
Or can my initial approach be considered to implement doing only one thing, since it is making a part for Project
and another for Ticket
?