Hacker News new | ask | show | jobs
by karmajunkie 4518 days ago
That doesn't make it any less of an antipattern. The "fat model" pattern is essentially "if you can't figure out where it goes, put it in the model." In the article's example, the credit card processing code is wrapped up into the quote model. I can't think of a single situation in which this is a good idea.
1 comments

The "fat model" pattern is simply organising your logic and relationships into the model layer. How well you organise it is up to you. If you just dump things from the controllers into random parts of the model then that's your choice but there are plenty of ways to design it well.
I'm closely involved in a big system that uses Catalyst (perl's nearest equivalent to Django). We spend allmost all of our time in Model classes (MyDomain::Model::Whatever, not MyWebApp::Model::Whatever that's just a dumb connector). It works well and I get the shits every time I have to deal with code that doesn't separate this stuff out properly. Also works on the front end using modern javascript.
I have most of my logic in the views (because I didn't now any better when starting my project). I know the Django way suggests fat models (well I know that now). But is it honestly that big of a deal? I know in my app that any complex logic will be in the views. What will I gain by following these best practices?
Yeah, try having a fat controller or view, on a rapidly developing codebase with poor specs which change mid-project regularly while avoiding getting fired.
Sounds very like my work.

Yeah, schema changes are a pain in the arse, but I don't see that moving my code from views to models would have a great deal of impact (though I am gradually moving the code that way when it does need changed).

A better answer is, that you get to decouple the functionality of your application's business logic from the web portion. This is achieved trivially purely by applying disciplined coding standards. Removing the web dependency makes the code much much easier to write automated tests for, and it gives a sane development path when making minor or major changes to feature sets.