Home arrow PHP arrow Using Self-Saving Objects with Command Objects in PHP 5

Using Self-Saving Objects with Command Objects in PHP 5

If you were looking for an approachable guide on how to create and use command objects with PHP 5, then look no further, because your search is over. Welcome to the final part of the series “Creating command objects with PHP 5.” Comprised of three comprehensive tutorials, this series walks you through the basics of how to apply the command pattern in PHP, and it accompanies its corresponding theory with numerous code samples.

TABLE OF CONTENTS:
  1. Using Self-Saving Objects with Command Objects in PHP 5
  2. Defining a core module of the command pattern
  3. Storing and loading self-saving objects
  4. Completing the command pattern
  5. Seeing the command pattern in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 8
December 26, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Certainly, one of the things that you’ll surely recall from the preceding article is the fact that implementing the command pattern with PHP is a quite straightforward process which can be carried out with minor problems. As you learned before, the procedure is only limited to defining a specific class, dubbed “commanded,” which will expose a method capable of encapsulating all the logic required for execution in another object. Lastly, this second object involved in the relationship is called a “commander,” and it will take care of invoking the mentioned method inside of its own scope. That's fairly understandable, right?

Of course, one of the best courses of action to take when it comes to explaining the logic that stands behind the command pattern is to develop some concrete examples. In this way you can see how these objects interact with each other, as well as the neat functionality of this pattern.

Now, and focusing my attention specifically on the topics that I plan to discuss in this final part of the series, I’m going to extend the creation and use of command objects to use the pattern in a more helpful fashion. Essentially, I’m going to explain how to utilize command classes for defining and handling self-saving objects, that is objects capable of storing a copy of themselves on a database, text file, etc.

By doing so, I'll give you a much clearer idea of how the command pattern can be used in real-world applications, and at the same time you’ll expand your existing background in using design patterns with PHP 5 as well.

With the preliminaries out of our way, it’s time to find out together how to use commanders in the creation of self-saving objects. The experience will be really educational, so let’s get started!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap

Dev Shed Tutorial Topics: