Questions tagged [command-pattern]

The Command pattern is a Gang of Four behavioral design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

The Command pattern is a Gang of Four behavioral design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time.

The object used includes the method name, the object that owns the method and values for the method parameters.

Typical uses of the Command pattern are, among others:

  • Undo
  • Transactional behavior
  • Wizards
  • ThreadPools

This is one of the Gang of Four's behavioral , first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".

More information is available on Wikipedia.

303 questions
0
votes
1 answer

Command Design Pattern is implemented with some mistakes?

Here in Russian Wikipedia link there is an example of C++ implementation of Command Design Pattern. As I understand from the implementation comparing with the UML class diagram I see that: class Document is the Invoker in the diagram class Command…
Narek
  • 35,407
  • 69
  • 202
  • 359
0
votes
1 answer

Ways to attached an ICommand to a control in XAML

I'm very new to XAML. To utilize MVC architecture and the Command Pattern while taking advantage of XAML, I have started binding static ICommands to Buttons. I'm working on a fairly large project with over a hundred buttons. My questions are: are…
0
votes
1 answer

Serializing/Deserializing Command Object

I'm attempting to serialize (and later deserialize) a command object to a string (preferably using the JavaScriptSerializer). My code compiles, however when I serialize my command object it returns an empty Json string, i.e. "{}". The code is shown…
Bern
  • 7,102
  • 5
  • 31
  • 46
0
votes
1 answer

Keeping track of parameters using a Command Pattern and ICommand for Undo/Redo. Storing multiple commands?

I've been working on a WPF application that involves moving many shapes. It is mostly MVVM and relies heavily on commands. I had not worried about Undo/Redo until just recently. I don't think it will be too difficult since most of my changes involve…
0
votes
0 answers

Switching frames with command pattern

I'm trying to create an intro animation for my flash game, but when it's supposed to go to the second frame of the animation things go wrong. This is the code (located in the document class) that the start game button in the menu is supposed to…
Berry
  • 119
  • 11
0
votes
1 answer

2 kind of command in Command Pattern

I'm developing application using Command Pattern. I have two kind of operations in my programm: 1. Long time operations (copy/delete files), which should be run asynchronously 2. Simple operations (refresh panels) My question is: Can I implement…
Mikhail Sokolov
  • 517
  • 1
  • 7
  • 17
0
votes
4 answers

Mixing Command pattern, Factory pattern and templates all together ...

I already asked a similar question here, however I didn't really get the answer I wanted because my question was poorly formulated and the examples were bad. So I give it another shot, with hopefully a better explanation and better code . The code…
Dinaiz
  • 2,123
  • 3
  • 21
  • 29
0
votes
2 answers

Using template template parameter on function call

Actually, all the answers are nice, and informative but they don't solve my particular problem. I don't think that's the fault of the very helpful people who replied but instead, I badly phrased my question. Therefore I decided to post a completely…
Dinaiz
  • 2,123
  • 3
  • 21
  • 29
0
votes
1 answer

How to integrate the GWT command pattern with spring

I have a project where I am using the GWT command pattern to implement the RPC. Here how i can integrate the Spring with GWT. Without Spring I am able to achieve the RPC. But here i need to use Spring Dependency Injection for GWT server side…
Saritha
  • 181
  • 17
0
votes
1 answer

Isn't Command Pattern an implementation of Dependency Inversion Principle?

Command pattern has three main components: the Invoker, the Command and the Receiver. Client provides the Invoker with information required to call a particular method M on a Receiver, while it is Command object ( which is housed by Receiver ) that…
-1
votes
1 answer

I dont get how command design pattern works in game development

Maybe that's my lack of c++ knowledge or lack of programing skills, but i'm trying to understand command design pattern in c++ for game development. I'm reading this book (its literally called "Game Programing Patterns" and i quite like it), and i…
-1
votes
1 answer

Using Command- Pattern to create an object and add this to an ArrayList

I have a Problem to understand the exercise. What I have to do is: Different users must be able to add and delete a ticket to a ticketsystem (in a List) I have to do this with the Command- Design- Pattern But I actually don´t know how to do…
-1
votes
1 answer

What are good practices to parse tokens from a users input?

I am implementing a system where the user should feed my program a command. I then split up the string of their input into tokens, delineated by spaces, stored in a vector. My initial idea was to use a bunch of if-else statements to determine which…
Aaron
  • 381
  • 1
  • 6
  • 16
-1
votes
1 answer

What is the best way to instantiate a class using Reflection with the polymorphism?

I'm trying to use Reflection in java to instantiate a Player with a Command Pattern likes below : There is only one 'execute' method in a Command class, And the InitiatePlayerCommand as its name , it will instantiate a subclass of Player…
OOD Waterball
  • 618
  • 8
  • 23
-1
votes
1 answer

I want to enable the a particular column of my dataGrid to edit on button click

I want to disable(close for editing) the 3rd column of my dataGrid(using MVVM-WPF) but want to enable to edit again on click of button outside the Grid.How can I achieve that? The Challenge I am facing here is how to retrieve dataGrid's property…
Chanchal
  • 47
  • 1
  • 8
1 2 3
20
21