Exforsys

Online Training

Model, View, Controller question

This is a discussion on Model, View, Controller question within the Software Patterns forums, part of the Testing category; I'm experimenting with a MVC pattern. It's new to me, but I'm getting on fine with it. ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-26-2003, 12:36 AM
Derek Fountain
Guest
 
Posts: n/a
Model, View, Controller question

I'm experimenting with a MVC pattern. It's new to me, but I'm getting on
fine with it. A question:

Is it OK to have part of the model data inside the view widgets?

The answer, at first glance, seems like "no", but here's the position: I
have a bunch of text widgets which the user fills in, then they hit a
button which says "do it". The view sends the "do it" signal to the
controller, which relays it to the model. At this point the model needs the
text in those widgets to start work.

The options seem to be:

1) Have the view and controller update the model each time the text widgets
are altered. The model keeps an up to date representation of what's in the
text widgets. This is slow and duplicates data.

2) Have the controller query the view for the contents of the widgets when
it gets the "do it" signal. It can then pass the complete information to
the model.

3) Have the model query the view for the text when it needs it.

"2)" seems the obvious way to go, but that communication doesn't fit any MVC
diagrams I've ever seen to date.

The question goes a little deeper than just text widgets. For example, I
have a listbox containing a list of filenames which can be added to,
deleted from, and reordered using buttons on the GUI. At the moment I have
the list of filenames stored in the model as well as in the listbox widget.
When the buttons are clicked, signals are passed around to the model which
updates it's structure, then signals the view to update. That seemed the
correct way at the time, but it means duplication of data and hence
possible inconsistency. Perhaps the view should look after the list and
only pass the contents into the model when the model actually needs it?

What's guidelines are there for this issue?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:22 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.