Re: Command pattern: Interaction allowed?



"tailorma_de" <tailormade@xxxxxxx> wrote in message
news:1164029960.765972.111690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In a command of the command pattern, would you say that interactions or
callbacks are allowed? E.g. if there is command 'Delete', is it okay if
the command calls a function that asks the user 'Are you sure?' and
then do the deletion or not? I guess this wouldn't be advisable since
it obscures the pattern somehow. Well, it is a simple example. The
assumed interaction could be more complex. Consider a dialog in an IDE
where one could choose which files to store when the user has clicked
on 'Close Project', i.e. the CloseProjectCommand is triggered.

However, when I think of the alternative it yields some disadvantage as
well. Consider the CloseProjectCommand: Before the command is actually
triggered the unsaved files have to be figured out, the dialog has to
be shown and some SaveFileCommands have to be called. And where would
be this logic for these steps? Would it be part of the business model?
It should, I guess, but I don't know how to realize this. From my point
of view this would be part of a 'higher' level, and this would be the
UI. What is not okay - I know.


It is perfectly OK to have the U/I present the dialog BEFORE calling the
command. In other words, the command is called by the U/I when the U/I is
certain that it wants the command to occur, and not before.


--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--


.



Relevant Pages