BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to map self-induced model changes to a selection?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Malte Persike
Guest





PostPosted: Wed Nov 26, 2003 3:05 am    Post subject: How to map self-induced model changes to a selection? Reply with quote



Hi there,

consider a simple alarm clock as a model in a MVP framework. The time
can be modified by a user command but, of course, it increments itself
at least every second.
The selection might contain alarm times or even parts of the current
time itself, e. g. when the user wanted to reset only the hour and
therefore selects the hour digits in the view.

How would the automatic time update done by the clock itself be mapped
into the selection? Ought the selection to observe the clock model and
adjust its value on notification or would the model spawn some kind of
command which then operated on the selection?

Kind regards,
Malte

---

The above e-mail address is not valid. To
contact me, please use my real e-mail address:

malte AT t DASH online DOT de
Back to top
Joanna Carter (TeamB)
Guest





PostPosted: Wed Nov 26, 2003 9:04 am    Post subject: Re: How to map self-induced model changes to a selection? Reply with quote



Malte Persike wrote:

Quote:
consider a simple alarm clock as a model in a MVP framework. The time
can be modified by a user command but, of course, it increments itself
at least every second.
The selection might contain alarm times or even parts of the current
time itself, e. g. when the user wanted to reset only the hour and
therefore selects the hour digits in the view.

How would the automatic time update done by the clock itself be mapped
into the selection? Ought the selection to observe the clock model and
adjust its value on notification or would the model spawn some kind of
command which then operated on the selection?


I think what is needed here is to use the Interactor to detect when an
editing keystroke happens in the View and suspend the View's ability to
update itself until the edit is complete. At which point the View would once
again start reacting to updates in the Time model.

You might also want to consider splitting the concept of Time into Hours,
Minutes and Seconds 'sub-models' and having the View also contain
'sub-views' ??

Joanna

--
Joanna Carter (TeamB)

Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker



Back to top
Malte Persike
Guest





PostPosted: Wed Nov 26, 2003 1:37 pm    Post subject: Re: How to map self-induced model changes to a selection? Reply with quote



Hi Joanna,

this is evolving into some kind of masterclass. Thanks a lot!


Quote:
I think what is needed here is to use the Interactor to detect when an
editing keystroke happens in the View and suspend the View's ability to
update itself until the edit is complete. At which point the View would once
again start reacting to updates in the Time model.

Umph, Interactors again ;-)

Your suggestion seems to imply that the selection is out-of-date most
of the time. Only when the user attempts to change the time, the
selection becomes updated and then holds the last current time until
the user exits the time-edit field again.
The difficulty I see with this solution is the fact, that one could
easily imagine a model that switches its state autonomously during
program execution in such a way that the new state needs to be
reflected in the command set.

A MediaPlayer playing a single sound file, for example, will at some
time reach the end of that sound file, which will affect various
capabilities of the media player, like no longer being able to
play-back, fast forward or skip forward. These changes in player state
need to be reflected by the command set and subseqently by the visual
controls (en-/disabling buttons). In my MVP design the command set
only updates itself when it receives a notification from the
selection.
But if the selection is not informed on-time about changes of the
model, it cannot signal them to the command set.

Kind regards,
Malte

---

The above e-mail address is not valid. To
contact me, please use my real e-mail address:

malte AT t DASH online DOT de

Back to top
Joanna Carter (TeamB)
Guest





PostPosted: Wed Nov 26, 2003 2:17 pm    Post subject: Re: How to map self-induced model changes to a selection? Reply with quote

Malte Persike wrote:

Quote:
The difficulty I see with this solution is the fact, that one could
easily imagine a model that switches its state autonomously during
program execution in such a way that the new state needs to be
reflected in the command set.

Then, because the Model has changed state, it has to inform the Command Set
that it owns; just because the Command Set is an Observer of the Selection
doesn't mean that other objects can't talk to it.

If you implement such Models as State Machines, then you can stop further
changes to the Selection/Command Set happening.

Better still, why don't you have a go at writing a Clock MVP and then we can
all pull it apart :-)

Joanna

--
Joanna Carter (TeamB)

Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker



Back to top
Bob Dawson
Guest





PostPosted: Wed Nov 26, 2003 3:05 pm    Post subject: Re: How to map self-induced model changes to a selection? Reply with quote

"Malte Persike" wrote
Quote:

How would the automatic time update done by the clock itself
be mapped into the selection?

Follow your own suggestion and look at how the editing works for the clock
in the system tray: the presentation layer subscribes to and reflects system
updates until specifically thrown into an edited state, at which point it
stops updating until either apply or cancel are directed.

bobD



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.