Skip to main content
added 34 characters in body; edited title
Source Link
Glorfindel
  • 3.2k
  • 6
  • 28
  • 34

is Is it bad practice that a controller callcalls a repository instead of a service?

isIs it bad practice that a controller callcalls a repository instead of a service?

toTo explain more:

I figure out that in good design controllers call serviceservices and serviceservices use repositoryrepositories.

butBut sometimes in controller I don't have/need any logic and just need to fetch from dbthe database and pass it to the view.

andAnd I can do it by just calling the repository - no need to call the service - is it. Is this bad practice?

is it bad practice that controller call repository instead of service?

is it bad practice that controller call repository instead of service?

to explain more:

I figure out that in good design controllers call service and service use repository.

but sometimes in controller I don't have/need any logic and just need to fetch from db and pass it to view.

and I can do it by just calling repository - no need to call service - is it bad practice?

Is it bad practice that a controller calls a repository instead of a service?

Is it bad practice that a controller calls a repository instead of a service?

To explain more:

I figure out that in good design controllers call services and services use repositories.

But sometimes in controller I don't have/need any logic and just need to fetch from the database and pass it to the view.

And I can do it by just calling the repository - no need to call the service. Is this bad practice?

Question Protected by gnat
Tweeted twitter.com/StackSoftEng/status/1185254387876323330
Source Link
mohsenJsh
  • 1.4k
  • 1
  • 11
  • 15

is it bad practice that controller call repository instead of service?

is it bad practice that controller call repository instead of service?

to explain more:

I figure out that in good design controllers call service and service use repository.

but sometimes in controller I don't have/need any logic and just need to fetch from db and pass it to view.

and I can do it by just calling repository - no need to call service - is it bad practice?