4 ms·
I generally accept the point made in the article, but what should I use in place of "Controller"? If using MVC I generally call it "ApplicationController" or "S
by philbarr 15y ago
I generally accept the point made in the article, but what should I use in place of "Controller"? If using MVC I generally call it "ApplicationController" or "SimpleController". Should it be "Application", "ApplicationControl"...?
- lallysingh 15y agowhat do the controllers actually do? Synchronize state? Verify that constraints are met?
- dasil003 15y agoI believe the OA's intended question is what are the controllers? Well, what are they? Yes, I know they control things, but what is the actual thing that they are?
- philbarr 15y agoYou're suggesting I call them "StateSynchronizer" or "ConstraintVerifier"?
- lallysingh 15y agoNo, I suggest you name it after what it actually does. "Controller" is a role that's only defined in terms of what it interacts with. It's essentially a declaration of rank with other types; it doesn't say anything about what functionality the class provides. If I'm looking at the components of the software, and I want some code to do X, or wonder what a class Y does, what does "Controller" tell me? If you're doing constraint verification (for example), my preference is to have a container (e.g. vector<>) of Constraint and just run find_if() to see when Constraint::Valid(environment) returns false. Then it's a class called ConstraintVerificationUtil and it has a single static method: VerifyList.
- deleted 15y ago[deleted]
- philbarr 15y ago"Controller" says to me that it's the where all the events are dealt with, so I can have one single place where events are handled. As for "ConstraintVerificationUtil", I personally feel that things that end in -Util are definitely worse than things that end in -er. Maybe that is just personal preference.
- davvid 15y agoArcade games are a good analogy for MVC. The controller is the joystick, buttons, etc. The view is the CRT screen. The model represents the game state.
- gruseom 15y agoFrom the OP: "The fact that every single MVC implementation in the world has had a different role for Controller ought to tell us something about how well that idea fit." We were just discussing this yesterday: http://news.ycombinator.com/item?id=3036153 http://news.ycombinator.com/item?id=3036153. A favorite principle: when you can't find a good name for something, it's often a sign that the concept you're trying to name isn't appropriate.
- philbarr 15y agoWhat I still don't understand is, what would I put in place of the Controller? Events are raised by the user, these are all fired off and I want to handle them in the same place in the same way. I certainly don't want event handling code all over the application just because this means I can then have noun-only classes?