Skinny Controller, Fat Model

Just ran across some really great videos on MVC done by the guys at RailsEnvy in the style of public service announcements. "Controller Obesity" is particularly noteworthy. One of the things we preach in our Mach-II training (you took our training survey, right? :-) is to keep your controllers as dumb as possible. I'm starting to think "skinny" is a more apt description than "dumb" since the controllers provide very important functionality, but making them too fat limits the flexibility and reusability of the model layer, which is where you spend the bulk of your development time.

Comments

Skinny is nice... depending on what you are building. One pattern fits all isn't a complete reality just the same. What percentage of the time would this be true... what are the design factors that state when skinny is better. (Or is it we should just make it skinny so we don't have to think about when it would be a better design for it not to be skinny?)

Absolutely John--there's never a single hard-and-fast rule that will be universally applicable. As a general rule, however, I think this is a good one because--at least where development frameworks are concerned--one of the big mistakes people make is to put too much business logic in the controller layer.

Great, I am working on a OO book for beginners... work in progress and was wanting an opinion. Do you think we should list things as 'rules' general or should we use 'rules' for some items and 'principles' or 'guides' (or some other term for the others)... in the end my hope is to give the new OO people more of a weighted consideration... true most of the time, some, mix... so they don't go brain dead when intelligence tells them something is an exception.

@John,

I think at first, people learn best using hard-fast rules. When people don't know concepts, you can't have them using judgment. Judgment comes with experience and until there is experience, there must be strong guides.

You are free to seek to prove your theory as correct. Just find a number of teaching styles and do the statics to show your theory right and get back with me. :) Until then I will take the experience of working with people and teaching a bit longer than you as a louder voice. Nothing personal... but it's the Mix. Not either or... and people learn to walk without hard fast rules being the only guide. Key is to keep them away from the stairs while they learn. I am sure both methods will work better for different people. Sorta the left brain right brain thing, you know. (Or check it out.)

On reviewing that post... let me rephrase. :) I agree mostly Ben... but was trying to get at different people have different learning styles. There are also things we learn to do best organic... and my belief is getting the organic up and running can prevent those who just never like to think from getting more dangerous by learning more and more and still not knowing how to think and use judgment. (Hope that clarifies what I should have said.)

@John--I think your equating "strong guides" with "hard and fast rules" and that isn't the case. As a general statement, keeping your controller skinny and your model fat is 100% accurate. The point is if you start dumping business logic into the controller, that's not where it belongs.

Re-reading your first comment I'm not sure you're taking this guidelins in a specific enough manner to really grok what it means. In framework-based development, you'll have a controller. What I've seen time and time again as I've taught Mach-II both to co-workers and in training over the past several years is a tendency to put too much of the business logic in the controller layer. This is a common enough problem that from my standpoint I'd certainly say that "keep your controller skinny" is a good general guideline.

Once you get into the particulars of a specific application or situation this statement can become more concrete, and you can say "that code doesn't belong in your controller, move it to your model." But specific to controllers, keeping them as skinny as possible is certainly a good general rule and one that I use constantly (although previously I'd been using "dumb" or "detached from the business logic" as my description) to reinforce this point.

Again, this is probably one of the most common mistakes people make when they're first getting into MVC development, so while we can debate specific situations all day long, it's still a great general rule.

I agree with your post in general and am not at all interested in the specifics debates either.

One of the most difficult things for new people is to know what the controller actually is. What I see is people who follow MVC fail to teach a "strong guide" as what the controller is and what it isn't. On that it also apparent that there are variations on the MVC pattern... though a good pattern many times it appears people describe what they are doing as MVC. What is wrong with this... well, when we move from one framework to the next it seems the definitions of MVC components get blurred. Let me give an example outside the business logic. We look at skinning and CSS, is that part of the view or does the view work with it? Should there be separation of concerns here... or should does it matter. (I agree with the popular statement here actually... 'it depends'.) Well with that stated here is my point. We have a picture of what MVC means... new people don't. Looking at all the different frameworks it is clear that our definitions are not as 'concrete' as we might think.

This is why I refer to learning to walk vs learning to assemble. Hard and fast rules may teach us a few things about software but the road to understanding OO and MVC and (fill in your hot topic here) is experience. Experience is best gained in practice rather than boot camp. I believe there is a great benefit to boot camp, but it seems the real world is very good at not matching our training. You could say the best training is the one that teaches you to react to 'real world' challenges with organic thinking vs. residual immaturity of highly rigid thinking that these rules always apply without understanding why.

These Ugg New Tall Boots are very cool and well built. Great quality at an affordable price.wonderful womens locarno boots. I'd buy these Black Ugg Boots again.

My girlfriend received the Ugg Bailey Button I bought her for her birthday, she adores ugg boots, So I’ll be back before Christmas buy more Black Ugg from you.

UGG Locarno Boots don't come cheaper either the original ugg 5389 boots Australia brand which hit Ireland circa 2006, costs 220 and upwards, with new styles like the Ugg Sundance gracing the shops this year.

53.These high-end designers like to see UGG Boots KnightsBridge! You will definitely impress your friends come to when you walk in your new boot.Fashion is looking good, warm and comfortable. All infants erin baby boots are fit for these standards. You will feel you are surrounded by warmth.This winter make your fashion is your Ugg Short Boots.

Excellent reproduction replica rolex sells at resonable price.The rolex replica paypal with high quality and exclusive design.Choose one amazing of replica watch paypal to highlight your life style.

Thank you.Hot Shoes Cheap Jordan shoes michael jordan shoes and are on sale-Free shipping.

thanks

good

nice

As the business grows, rolex replica has also jumped into an international brand. It is worth mentioning that, replica rolex paypal is the ancestor of today's brand-oriented, in order to protect the quality and brand name will be printed on their products, the history of fashion in the world, is the first one first.

replica watches paypal

rolex replica paypal

replica watch paypal

Vacheron Constantin replica

Rolex replica

Rolex Air-King replica

Rolex Datejust II replica

xxx replica

as

Very happy I can comment here!

Best wishes for this year.

Interesting thing!

This looks awesome! Thank you for your information!

The federal government will pay men's watches 100 percent of costs for covering newly eligible replica breitling individuals through 2016. A special deal that would have given Nebraska 100 percent federal financing women's watches for newly eligible Medicaid men's watches recipients in perpetuity is eliminated. A different, one-time replica breitling watches deal negotiated by Democratic Sen.

welcome to buy mbt shoes

new style with free shipping 40% off offering.

It's so lucky for me to find your blog! So shocking and great! Just one suggestion: It will be better and easier to follow.

http://www.airjordanshoe23.com/

http://www.sneakershoebay.com/

http://www.christianlouboutinsaling.com/

ed hardy t shirts,

discount uggs boots or

cheap ghd straighteners,

christian louboutin boots and 

discount ugg boots as well as 

p90x workout,

air jordan shoes,cheap authentic nfl jerseys,

chi hair straightener t shirts. i think more and more people would comr to read your blogs.

Wow, thanks for the insightful post. I look forward to reading more from you.