From the course: ASP.NET MVC: Building for Productivity and Maintainability
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Moving business logic from a controller to a service
From the course: ASP.NET MVC: Building for Productivity and Maintainability
Moving business logic from a controller to a service
- [Instructor] In this video, I'm not going to talk about any specific ASPNET NBC feature. Instead, I'm going to focus on another practice that folks are often encouraged to follow in tutorials, an approach that may work fine for a small application but it starts to become a problem as an application grows in size and complexity. In fact, this issue is so common it actually has a name. They call it the fat controller pattern. For example, check out the update action on the inventory controller which I've updated to use the request object pattern that I showed in the previous video. Now the problem is even with the conversion to the request object, this method is still so long it doesn't even fit on the screen. As you read this code, keep in mind that the purpose of the controller in the model view controller pattern is to orchestrate interactions between the model and the view. Judging only by the length of it, this method is almost certainly trying to do too much which usually…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Reducing duplicate code with custom action filters5m 49s
-
(Locked)
Creating explicit contracts with request objects6m 51s
-
(Locked)
Moving business logic from a controller to a service7m 10s
-
(Locked)
Consuming a service from a controller3m 11s
-
(Locked)
Challenge: Creating a model validation action filter2m 7s
-
(Locked)
Solution: Creating a model validation action filter3m 55s
-
(Locked)
-
-
-