The best way to link Model and Controller in an MVC application

The best way to link Model and Controller in an MVC application

Post by Phli » Sun, 29 Mar 1998 04:00:00




>Most of my experience lately has been from the Microsoft Foundation
>Classes, where things are just Document/View, and the controller is
>lumped in with the view.

Nobody put a gun to your head and told you _not_ to introduce a Controller
between the View and Document, hm?
 
 
 

The best way to link Model and Controller in an MVC application

Post by Ralph Richard Co » Mon, 30 Mar 1998 04:00:00


Most of my experience lately has been from the Microsoft Foundation
Classes, where things are just Document/View, and the controller is
lumped in with the view. There, the controller knows how to get to
data in the document because the view knows how to get to the
document.

I'm doing some Java programming and want to do true MVC with 1.1 type
event listeners. I'm left wondering what is the best (you know, least
coupled, most cohesive, all that good stuff) way of letting the
controller know about the model. Is the controller passed a reference
to the model at its construction? Does it find out about it
indirectly, by asking the view that it's linked to? Is there another
way I'm not thinking of?
----------------------------------------------
Ralph Richard Cook's Java Opinions and Applets
http://personal.atl.bellsouth.net/atl/r/a/ralphc/java/

 
 
 

The best way to link Model and Controller in an MVC application

Post by Charles R. Mart » Mon, 30 Mar 1998 04:00:00




> >Most of my experience lately has been from the Microsoft Foundation
> >Classes, where things are just Document/View, and the controller is
> >lumped in with the view.

> Nobody put a gun to your head and told you _not_ to introduce a Controller
> between the View and Document, hm?

It's not that easy -- when you use MFC, the View as derived from CView
(Voyage to the Bottom of the Sea music here) has the necessary goodies
to catch window and key events.  You *could* interpose a Controller, I
suppose, but that would just be duplication, and that would be Wrong.

But then the display and control stuff are so coupled in the Windows
model that the Controller and View are practically in each other's
laps all the time anyway; it's a perfectly reasonable solution to take
the Document/View division.

 
 
 

The best way to link Model and Controller in an MVC application

Post by Phli » Mon, 30 Mar 1998 04:00:00





>> >Most of my experience lately has been from the Microsoft Foundation
>> >Classes, where things are just Document/View, and the controller is
>> >lumped in with the view.

>> Nobody put a gun to your head and told you _not_ to introduce a
Controller
>> between the View and Document, hm?

>It's not that easy -- when you use MFC, the View as derived from CView
>(Voyage to the Bottom of the Sea music here) has the necessary goodies
>to catch window and key events...

So the answer is "yes".

But could someone reply to the original question? I'v kinda waylaid it...