Controllers in the MVC pattern is not a replacement for Business logic layer

I have seen several demos and examples on presentations where the Controllers are more or less used as a Business logic layer and based on the definition of the MVC Pattern, that is not the correct way of using the Controller. The Controller in the MVC is not a replacement of the Business Logic Layer. The Model in the MVC is the Business Logic Layer. The Controllers purpose is to be a contract between the View and the Model, and handle user actions. Think of the Controller like the Web Form's Code-behind, the logic you put in the code-behind can sort of be added to the Controller, the benefit you get by using MVC over Web Forms is that you can now with the MVC write unit test to test "complex" presentation layer code, and it's not easy to write test against the code-behind because it's event driven.

The correct design when using the MVC would be:

Presentation (View) -> Controller -> Business Logic (Model) -> Data source

When using the Domain Driven Design, the Controller will work against the Service/Application Layer or the domain model, if we work with a old traditional n-tier architecture, the Controller will work against the Business Logic Layer.

Published Monday, December 01, 2008 7:55 AM by Fredrik N

Comments

# re: Controllers in the MVC pattern is not a replacement for Business logic layer

Monday, December 01, 2008 2:11 AM by Craig

Fat Model, Skinny Controller. Need to remember that.

# ASP.NET MVC Archived Buzz, Page 1

Monday, December 01, 2008 4:55 AM by ASP.NET MVC Archived Buzz, Page 1

Pingback from  ASP.NET MVC Archived Buzz, Page 1

# Interesting Finds: December 1, 2008

Monday, December 01, 2008 10:45 AM by Jason Haley

# re: Controllers in the MVC pattern is not a replacement for Business logic layer

Friday, January 30, 2009 3:32 AM by linus

Hello!

I saw you on pimp my code the other day, and you mentioned something about the difference between rebate and discount.. i think your definition was wrong ;-)

You might want to check it out before you mention it in public again :-)

for example:

dor.wa.gov/.../Auto_DiscRebates.aspx

But dont take my word for it, i only checked out very few sources..

/L

# re: Controllers in the MVC pattern is not a replacement for Business logic layer

Friday, January 30, 2009 3:44 AM by Fredrik N

Hi Linus,

It would be much better if you could drop this as an e-mail instead as comment to a blog post ;)

I did a similar presentation for a while ago (in English), and I asked one of the attendees from England what are the different between Discount and Rebate.. and he said that Rebate is often used when there is a fixed price, like £10, and Discount when there is a % number. Did you attend the Gothenburg event or the one in Stockholm? Because in Stockholm I asked if the attendees if anyone known the different and one of the attendees said, yes, the Rebate is a fixed price. Please, instead of answering this comment here on the blog, drop me an e-mail.. I would like feedback like this.. and all kind of feedback are welcome.. fnormen [a] hotmail.com

# re: Controllers in the MVC pattern is not a replacement for Business logic layer

Monday, March 29, 2010 6:28 PM by Iain.W

We said!

It amazes me the ranting from some about how MVC gives so much cleaner seperation of concerns than web forms, and then you see DbConnections in the controller. Basics of n-tier/layer design seem to be forgotten (or never grasped).

Leave a Comment

(required) 
(required) 
(optional)
(required)