The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Should I use the Command pattern?

Is the command pattern the right tool for passing a prameter to for execution?

Option 1.
The non object-oriented solution uses the void *p idiom.

struct param
{
 void *p;
 int result;
}

class Executer
{
 f(void *p)
 {
  Action* act = (Action*)p);
  // use the Action object as needed
  ... 
 }
}

Option 2.
This is an object-oriented form (the command pattern)

class Command
{
public:
 virtual ~Command();
 virtual void Execute() = 0;
protected:
 Command();
}

class ConcreteCommand:Command
{
 void Execute()
 {
 }
 private:
 // data members
 ...
}

class Executer
{
 f(Command *p)
 {
  p->Execute()
 }
} Dale Lawrence
Dale Lawrence
Monday, September 11, 2006
 
 
Yes
Mike S Send private email
Tuesday, September 12, 2006
 
 
monkeY fueL
Tuesday, September 12, 2006
 
 
> I think you should use the "DO NOT CROSS POST" pattern

Huh ... I thought this post looked familiar, but I couldn't remember where I'd seen it.  Remember, a mind is a terrible thing to waste.
Steve Moyer Send private email
Tuesday, September 12, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz