I'm using an (C++) SDK (Marmalade) and building a project around the MVC pattern. On my app, user input listeners may be registered on certain UI elements/widgets/etc providing a proper callback function (according to MVC should be a method of a controller, right?).

In this scenario, who should register these listeners:

  • The controller? (must have access to the view UI elements, less decoupling of control from presentation)
  • Or the view? (direct access to UI elements but must have a reference to the controller, isn't this incorrect in MVC?)

Between the two, I think the latter makes more sense and does better separation of concerns, but I'm afraid that I overlooked some problem with that design.

Thanks in advance.

2 Answers 2


It depends on the type of MVC you want. I suggest you try the Michael Feather's "humble dialog box", which is also called "model view presenter (MVP)", and probably what you are looking for.

In this variant, the view has a refererence to the controller, and the controller has a reference to an abstract interface of the view. So the view can provide methods for registering listeners, those methods are also available in the interface, and the controller will call these methods without having direct access to the UI.

  • That "humble dialog box" is a great example. Reading this, I think that I should go more for a MVP architecture than a MVC one. Thanks.
    – pedrosanta
    May 20, 2012 at 15:47
  • The link is dead (HTTP Error 503). Is there any mirror?
    – Polygnome
    Mar 27, 2017 at 10:18
  • @Polygnome: link updated. Unfortunately, I could not find a reference to the original paper any more. But I guess by googling for the term, one will find enough information about the topic.
    – Doc Brown
    Mar 27, 2017 at 11:09

If I understand the question correctly, and I kind of doubt I do, the answer is none of the above. Registering event listeners with their sources should generally be the responsibility of a third part, a builder of some sort that constructs the system and starts it off.

  • 1
    Think about your answer in a scenario where listeners have to be dynamically registered and unregistered, not just at the time the system is initialized.
    – Doc Brown
    May 20, 2012 at 15:23
  • 1
    Yes, that's precisely my scenario. :)
    – pedrosanta
    May 20, 2012 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.