Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

what do the controllers actually do? Synchronize state? Verify that constraints are met?


I 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?


Arcade 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.


You're suggesting I call them "StateSynchronizer" or "ConstraintVerifier"?


No, 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.




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

Search: