Re: [gtk-list] Model/View/Controller?




Derek Simkowiak <dereks@kd-dev.com> writes:
> >From the GtkData docs:
> ----------------------
> The GtkData object is a very simple object intended to be used as a base
> class for objects which contain data (i.e. the 'Model' in the
> object-oriented Model/View/Controller framework).
> ----------------------
>

This should say, "GtkData is a totally useless node in the class
hierarchy. Ignore it."
 
> 	I would like to read more about the theory of "the object-oriented
> Model/View/Controller framework".  I have not seen those terms used
> before, and would like to understand them.
> 
> 	Any references (books? URLs?) are greatly appreciated.
> 

The book "Design Patterns" is a common reference, there's also a
whitepaper about MVC in Swing but I can't find it, this document has
some stuff about it:
 http://developer.java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html#JFCMVC

It's quite simple; it's just a matter of keeping your data in one
place, and having an arbitrary number of different displays of the
data and manipulators of the data. 

The rules to follow when coding: 

1) the data object (such as my GtkTextBuffer) should never directly
modify a single view, it should only notify a list of views of changes
via an abstract interface (signals are good).

2) views should never update their display because they know the
model changed, they should only update when the model informs them of
changes. That is, the following is broken:
 buffer.set_text("blah");
 view.update_display();

because update_display() should be called when the buffer notifies all
views that the text has changed.

If you follow those two rules it's hard to screw it up.

Havoc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]