Relationship between GUI and logic?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri May 23 10:58:00 EDT 2008


John Salerno a écrit :
> "Bruno Desthuilliers" <bruno.42.desthuilliers at websiteburo.invalid> wrote in 
> message news:4836747b$0$15488$426a74cc at news.free.fr...
>> Ever heard of the "Model/View/Controller" pattern ?
> 
> Yes, I have, but I probably don't understand it well enough yet. For 
> example, I don't  really know what is meant by phrases like "build a model",

An abstract, logical representation of your board and players, which 
have a state (ie : board has X cells, player1 is on cell (x, y) and 
player2 on cell (x', y')) and behaviour (ie : player2.move_to(x, y)) 
that changes the state.

> "the view registers itself with the model",

This is the Observer pattern. The view is passed the model when 
instanciated, and calls model.register(self). When the model changes 
it's state, it calls back the '.notify()' method of each of the 
registered views (a same model can have multiple views at the same time).

> "interactions are sent to the 
> appropriate controller"

In a typical GUI, the controllers are the event handlers (or are called 
from the event handlers - depending on how the GUI works). The system 
dispatch the events to the appropriate event handlers.

> -- I may understand them literally, but I get the 
> feeling that the implementation of these ideas are beyond me. I think it's 
> mainly an issue of terminology, so probably I should just read up on MVC.

Probably, yes !-)




More information about the Python-list mailing list