Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

Command Base Class

After the underlying object (LSP123) is created, we need to be able to execute operations against it. To do this, I use a generic Command class, as illustrated in Listing 5.

Listing 5 Simple Command Class

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

As with the Connection base class, the Command class in Listing 5 can be extended to allow for complex commands or operations on a variety of objects. The Execute() method is a placeholder for such commands. Let’s now assume that we decided to delete the entity LSP123 from Figure 1. So, we need a command object that handles deletion.

  • + Share This
  • 🔖 Save To Your Account