Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Controller Pattern Is Awful, Or, Stop Writing Stupid Classes (veekun.com)
12 points by sedev on March 4, 2013 | hide | past | favorite | 5 comments


For webapps, I agree. There is no progression of state in a webapp's "controller" object: it's one shot and done.

For native apps in frameworks like Cocoa Touch of course it's an entirely different ballgame. A view controller has quite a bit of state, usually some different modes, maybe some enforced state transitions. So the controller pattern makes a lot of sense there.

The author is spot on about how some architectural oddities like one-method-classes come from Java's lack of functions as first class objects.


Oh, sure. I don't mean "controller" necessarily in the sense of MVC; just the idea of using a class as a bag of unrelated functions. Web frameworks trying to be MVC happen to be the most egregious offenders.[1] I'd actually forgotten that I made up the name "controller pattern". :)

[1] I blame this on MVC not making sense for Web backends; the controller is supposed to make sense of a stream of realtime user actions, but that doesn't apply so well to the discrete request/response model of HTTP. Your URL layout itself is, in effect, already doing most of the work of a GUI controller, and what's left is a relatively small bit of glue between the model and view. (Pyramid even bills itself as an MV framework; it refers to request handlers as "views", rather than reserving the name only for templates.)


"Even if JavaScript lacked prototypes entirely, it would still be object-oriented as long as you could use this."

"Maybe you’d make a master object containing those methods, for ease of copying."

It's kind of hard to take a blog post about object-oriented style seriously when the author is unfamiliar with the definition of "object-oriented" and doesn't know what a prototype is in prototype-based programming.


Can you enlighten me?


Great post! Reconciliatory, yet pointed




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: