Dear LazyWeb:
I discovered the Model-View-Controller pattern earlier this year. Well, not discovered, I had read about it in OO programming articles years ago. And it’s been around for decades. But this year I think I’m finally getting it.
I think the reason I never got it was because I’d never encountered a system that used it very well, or forced you to use it. Everything I’ve worked on so far I now understand as very procedural, even in my C++ and Java classes things the OO part of it was not really emphasized more than you’re forced to for those languages.
Only some web apps I’ve worked on use objects, but mostly code with lots of functions in a global namespace. Lots of hokey validation everywhere, lots and lots of duplications to do things like CRUD and client-side validation. Now that I’m working with CakePHP (and previous dabbling with Ruby on Rails and much older experience with FuseBox and FuseBox II) I feel like I’m beginning to “get” it – like it’s in my head. I particularly have enjoyed using JavaScript in a hyper-OO way. Though I understand now that JavaScript is OO without the classes, making it sort of fundamentally wierd and different.
That said, I think what I’m ready for is some kind of “in the wild” book about OO programming and MVC, something that has some good background as to *why* MVC works how it does. Maybe not a book, but maybe essays? I feel like what I’m looking for is a articles with the theme “Thinking in MVC.”
Being so fresh to it I really have a hard time discriminating good writing about MVC vs. bad writing. I can’t tell a difference between what’s dogma and what’s really useful, especially where to not be so OO, and deciding where to create new classes and when not to.
Any and all suggestions for my intellectual stimulation are welcome.
Update 12/12/2006
Two books from O’Reilly:
And some good links for further study:
four comments so far...
[…] My post asking about MVC was updated. […]
As long as you have good fundementals – how inheritance, runtime polymorphism works, the diff between classes and objects, etc… MVC is not so hard to grasp. Think back to the old “traffic cop” analogy from way back. MVC is not that different, it just does things using objects and message passing instead of switch statements and passing strings around.
personally I find MVC to be a bit overblown for a lot of tasks. I really like the event-driven programming in ASP.NET which basically allows your views to talk directly to your model without worrying about how to dispatch the method calls around. Also, .NET kind of has a built-in controller which makes MVC a little troublesome. The article you posted above seems to have a whole lot of complexity around something as simple as a master-detail grid.
Look around the Struts community and you will see a lot of people who are not happy with MVC because it implements a lot of complexity. But as a pre-made app framework it definitely has it’s value.
Thanks Sassy.
The placement of the links on this post does not constitute endorsement. Try as I might otherwise, I dislike the .NET tools so far as I’ve worked with them. CakePHP and Django, on the other hand, appeal to me a great deal.
Oh, and I’ve found some good reading at the delicious listings for mvc: http://del.icio.us/popular/mvc