A
anonymous.user0
Ok, this is kinda dumb. I'm trying to wrap my head around the use of
the MVC and Command Patterns. The questions basically concern where to
place code.
In the MVC pattern, where are the Commands instansiated? Are they
created by the Controller, or are they contained fully in the Model.
In other words, if I had a button that I wanted to use to save an
object is it something like this (not real code obviously):
button_click {
saveCommand = new SaveCommand(params)
App.CommandStack.Push(saveCommand)
}
or something like this:
button_click {
object.Save();
}
object.Save(){
saveCommand = new SaveCommand(params)
App.CommandStack.Push(saveCommand)
}
Should the API to the Application contain all user functionality of the
application, or should the Application just be a Command stack without
any knowledge of the Command themselves.
example:
Application{
Login(string username, string passphrase);
Logout(string username);
EndApplication();
viewObjectType1();
saveObjectType1(ObjectType1 item);
associateObjectType1WithObjectType2(ObjectType1 item1, ObjectType2
item2);
viewObjectType2();
saveObjectType2(ObjectType2 item);
...
}
vs.
Application{
DoCommand(Command command);
UndoLastCommand();
}
How should User Interface commands be implemented. Should there be a
type of ShowFormCommand that is passed to the application? or should
the Forms handle navigation themselves?
Any help would be appreciated.
the MVC and Command Patterns. The questions basically concern where to
place code.
In the MVC pattern, where are the Commands instansiated? Are they
created by the Controller, or are they contained fully in the Model.
In other words, if I had a button that I wanted to use to save an
object is it something like this (not real code obviously):
button_click {
saveCommand = new SaveCommand(params)
App.CommandStack.Push(saveCommand)
}
or something like this:
button_click {
object.Save();
}
object.Save(){
saveCommand = new SaveCommand(params)
App.CommandStack.Push(saveCommand)
}
Should the API to the Application contain all user functionality of the
application, or should the Application just be a Command stack without
any knowledge of the Command themselves.
example:
Application{
Login(string username, string passphrase);
Logout(string username);
EndApplication();
viewObjectType1();
saveObjectType1(ObjectType1 item);
associateObjectType1WithObjectType2(ObjectType1 item1, ObjectType2
item2);
viewObjectType2();
saveObjectType2(ObjectType2 item);
...
}
vs.
Application{
DoCommand(Command command);
UndoLastCommand();
}
How should User Interface commands be implemented. Should there be a
type of ShowFormCommand that is passed to the application? or should
the Forms handle navigation themselves?
Any help would be appreciated.