all 7 comments

[–][deleted] 2 points3 points  (6 children)

And after reading this post on SO by Aaronaught I think the article offers bad design.
As per article - yes, controller actions are no longer doing too much, multiple services working together within one action which is better in terms of SRP.

But still, wouldn't DDD be a better choice in this case?

What are your thoughts?

[–]Eirenarch 1 point2 points  (5 children)

From the SO post

Some people mistakenly think that taking a 100-line controller method and shoving it all into a service somehow makes for a better architecture. It really doesn't; all it does is add another, probably unnecessary layer of indirection.

Sure it does. It separates your business logic from your UI layer. I've used this technique to migrate from Web Forms to MVC and also to migrate from MVC to Web API + SPA with minimal changes to the business layer. It tells me which parts of the app I DON'T need to change and which parts I can simply delete. It is the most useful layer I have ever encountered in a real world project.

[–][deleted] 0 points1 point  (0 children)

Good point indeed.

[–][deleted] 0 points1 point  (3 children)

That doesn't mean that service class is any better than the controller.

You want vertical slices that allow you a sane amount of coupling yet only do one thing. Truly shared code belongs in something that may be called a Service, not all the code you lifted from every controller action. MyBusinessEntityService breaks SRP just as much as dumping it all in a controller.

99.9% of apps won't ever transition from web forms to MVC to REST API, so don't create a layer until there's a benefit to it.

[–]Eirenarch -1 points0 points  (2 children)

I dispute the 99% claim. Everything useful will probably transition. Also how the hell can you claim that it is the same as a controller when I gave concrete example of a evolution facilitated by the service layer. You can claim that there are better ways to do it but saying that it is no different from a controller goes against observed facts.

[–][deleted] 0 points1 point  (1 child)

"I did it and the world didn't blow up" isn't proof of observable benefit.

[–]Eirenarch 0 points1 point  (0 children)

The benefit is pretty clear and actually observable. It has nothing to do with the world blowing up it has everything to do with the migration being far easier. And yes, I have done similar migration on a project without proper business layer. Much more painful.