共用方式為


Confusion over definition of Controller in MVC

I've got a frustrated anonymous poster who complains that my definition of ViewModel in Model/View/ViewModel is exactly that of Controller in MVC, and references Cocoa.

It appears to me that Cocoa has changed the definition of Controller from the original 1979 Smalltalk term.  In that framework, the Controller was responsible for mapping Input to the Model and the View. 

But according to the Cocoa definition I found on Apple's site:  https://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDesignPatterns/Articles/MVC.html

"A controller object acts as the intermediary between the application’s view objects and its model objects."

It appears Cocoa also recommends dividing the Controller into a model-controller and a view-controller, and if I read between the lines correctly, the view-controller is where view state would go.  I like this pattern rather a lot, but it is different from the MVC I have been contrasting with.

As an aside, I found a third way of looking at MVC in a old Java article:  https://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html .  Notice how the diagram shows Model in the middle, with View and Controller only talking through the Model.

Comments

  • Anonymous
    October 12, 2005
    The comment has been removed
  • Anonymous
    October 13, 2005
    Wouldn't a view-controller be the same as Fowler's presenter object in model view presenter?
  • Anonymous
    October 13, 2005
    My recollection from the eighties is that the Controller was commonly believed not only to map input, but to determine how that input affected the model. So it might have state machines as well. Essentially it handled user interaction.

    This was after the original Smalltalk but during the diffusion of Parc ideas into many other graphics systems.

    I believe this is still the best definition, as far as code organization, if you want to go that route.
  • Anonymous
    October 14, 2005
    I think that maybe an example of the Model/View/ModelView pattern would make things clearer. Allthough I am the first to admit that it is not easy to provide a simple example for a non-trivial pattern.

    Dirk
  • Anonymous
    October 15, 2005
    Seems to me that everyone has their own implementation of Model/View/Controller.

    John, let's see an actual example, as Dirk here suggests. I think it must really be simple to provide an example. If not, you ain't got a real pattern here.
  • Anonymous
    October 15, 2005
    Oh and by the way. As I see it, even your different references to Cocoa, Apple, SmallTalk and you 'very own' MVVC are all about the same thing: Model/View/Control, described from different perspectives.

    Try finding the pattern in all of these patterns. ;)
  • Anonymous
    October 16, 2005
    I have always referred to MVVM as a variant or refinement of MVC, with specific reliance on data-binding.

    As these things tend to go, work has gotten busy. I need to post more about data-binding and commands, then give an example. I just haven't had time.
  • Anonymous
    October 20, 2005
    Take whatever time you need to provide us with a good example. If you need another week, then I'll wait another week. If you need another month, then I'll wait another month. As long as the example has the potential to spark another intense week ;-)