Login  Register

Re: MVP design question

Posted by Chris Uppal-3 on Jan 14, 2005; 11:16am
URL: https://forum.world.st/MVP-design-question-tp3372678p3372689.html

Bill,

> Consider a time presenter that is a composite built for pen users; it's
> littered with buttons, among which is one labeled Now.  Also consider a
> time stamp presenter which includes the above and a date/time picker in
> the drop-down calendar mode.
>
> Obviously[*], the Now button needs to set the date when it is part of a
> time stamp presenter.  The question is how to do it.  Options include
> triggering an event and command routing.  Any preferences?

So, if I understand you, you have a button that should invoke one action in the
default context, but if the button's presenter is used in a different context
then it should do something (slightly) different ?

Like Ian, I think that I'd avoid the complexities of command routing here
(although its a perfectly valid technical solution, I think).  Some ideas, in
roughly increasing order of complexity (and generality):

1) (The /really/ simple suggestion) Make your button always generate a
TimeStamp (date-time pair), and let the context discard (or ignore) whatever
extra data it didn't need.

2) Give the time presenter a pluggable aspect #timestampBlock (or
#timestampFactory) which is
    [Time now]
by default, but which can be replaced by
    [TimeStamp now]
(or whatever) if needed.  The button's command would evaluate the block and <do
something> with the result.

3) Make the button invoke a generic #timestamp command which is /not/
implemented in the time presenter, but which must be provided by the context in
which it is embedded.

4) Ian's suggestion (slightly exotic, IMO, if I'm understanding it correctly).

5) (Another slighly exotic possibility)  Make the button's command a public
"aspect" of the time presenter, thus allowing you to plug in a different
command with a different effect -- perhaps an instance of
ClosedCommandDescription.

Without understanding your problem in detail, I suspect that I'd use (1) or
(2)...

    -- chris