Command Design Pattern

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
11,634
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Oct 5, 2009

This video will discuss about one of the most useful pattern of design pattern named Command Pattern.For more such videos visit http://www.questpond.com


For more free articles, interview questions and video tutorials, please visit http://www.questpond.com/

Link to this comment:

Share to:

Uploader Comments (dnfvideo)

  • It's trash.

    Your Invoker class is implementation of the Factory Method pattern.

    Invoker should calls a command, not returns it.

  • @PyanovEugen The invoker class does not create objects , so by no mean a factory method. It just has collection of command collection object. It gives out command object and the client can call the execute method.

  • @dnfvideo , Invoker's constructor creates 4 new commands (Exit, File, Open, Print in your example) and returns it by name. Client should use invoker JUST for commands execution with specific logic (History, Query ect).

    Not for creation and not for returning.

  • @PyanovEugen

    The first point of command object is to make a command a class , a object which already the Exit , File and open class is doing. That's the main meat of command pattern to make actions classes and objects to increase resuability.

    Now coming to the role of invoker , it just encapsulates things , helps for look up , helps for queuing must be and lots of other things. For me its just a look up now which returns the command object.

  • Cont If you are looking at the invoker class yes that class is just a wrapper , a factory. The role of invoker can mean different for different people , as you said it should not return a object , i say it can. At the end of the day its returning a generic interface so how does it matter.

see all

All Comments (16)

Sign In or Sign Up now to post a comment!
  • Thanks for the explanation.Command Patterns are generally used when you want to map user interactions with the system as commands to your system.What ever user does like click,drag,paste etc are all queued as commands to the system.Now why do we need to queue it and save its state because the user can always undo or redo his changes.To do be able to restore back the system should save its state,actions and commands.

  • Nice

  • Hey, thanks this was a great introductory vid. to the command pattern.

  • @GHaranadhGupta In normal games programming yo would like to use the double click mouse , sing click function again and again.

    One of the other use of Command pattern is Decoupling the UI ele,ments from BO functions.If you look at MVVM patterm where view intereacts with command objects who in turn invoke the BO at the back end. So the UI element btn_click_customer_add - mapped t- -- command object Add - mappend to customerbo.add method.

    View - Command Object - View model - Model

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more