I have a MVP Gui and now I would like to define certain Actions or Commands (Modify, Save, Close, …) for certain views.
Is there an easy way to do this? Should I provide Commands for each View?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to have a factory where all your command objects are instantiated. So if you have a open Job Command all the views would goto the factory and pull out the Open Job Command object, instantiate it, and then execute it. If you need to fix a bug or change the Open Job Command there only one spot you have to do it for all the Views.
With that being said there will be some commands that will probably be unique to each View. Despite that you may want to still encapsulate those in a command object as you can easily implement Undo/Redo with everything going through command objects.