I'm creating an app and I'm not sure if the structure of the solution is correct. I have a BaseController that uses generics. This controller is inherited by others that do not have to reimplement the code and just add functionality. The BaseController uses an IRepositoryService that has common logic to interact with our database using generics too and serves as a base class for other services like our CarService that has additional logic to make a Car interact with the database.


Then we have a SolutionService (and here is the part I have more doubts) that implements ICarService, IBikeService,ITruckSevice, etc. The SolutionService implements them by just having the same methods' signatures and then actually calling the corresponding CarService's method for example. All of these services inherit from RepositoryService, including the SolutionService.


In doing things like this, we can create any XController that inherits from the BaseController and uses the SolutionService abstracting everything. In turn, each service can call the RepositoryService and abstract the database interaction logic.


I think this can be improved, maybe I'm even doing something wrong as I'm new in designing a whole solution. Particularly I find it odd having to add the signatures manually to the SolutionService, maybe it could be improved through generics, interfaces, or something else? Or maybe the general approach is wrong. All feedback is welcome.

  • 1
    The SolutionService is unnecessary in my opinion. By having a class implement so many interfaces, you start coupling many concepts and ultimately don't achieve the advantage you are going for, which is abstraction. You would be better off in terms of design by calling each service in its specific controller. – Sebastian Sotto Dec 19 '20 at 22:06
  • It sounds like you are trying to make SolutionService acts similarly to a factory or some kind of manager with a mix of centralizing the method calls. Are the ICarService, IBikeService, and so on based on IRepositoryService or something else? – eparham7861 Dec 31 '20 at 14:59
  • @eparham7861 Yes – Emily Jan 1 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.