Home arrow PHP arrow The Singleton and Factory Patterns in PHP: designing an object factory

The Singleton and Factory Patterns in PHP: designing an object factory

This article, the second part of a series, is focused on implementing the Factor Pattern by designing a form element factory.

TABLE OF CONTENTS:
  1. The Singleton and Factory Patterns in PHP: designing an object factory
  2. The first step within the development process: coding form element classes
  3. Finishing the round: listing the rest of form element classes
  4. The Factory Pattern in action: developing the "formElementFactory" class
  5. Instantiating form element objects: a simple use of the form element factory
By: Alejandro Gervasio
Rating: starstarstarstarstar / 14
November 09, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

This is the second part of the series "The Singleton and Factory Design Patterns in the real world." Welcome back. Throughout the first part of the series, I provided you with an overview of building object-oriented forms using two popular design patterns: the Singleton and the Factory patterns.

At this point, I assume that these aren't foreign concepts to you, since they were reviewed in the first part. Just in case  you don't feel very seasoned with patterns, you should start by reading my previous article, where I offered a friendly introduction to them.

If you're used to writing a lot of repetitive code to build your web forms, probably you've found the technique that I previously explained to create forms, based on an object-oriented approach, quite interesting. Due to the advantages inherent in this method, form generation can be translated into a flexible and straightforward process that strongly encourages code re-use.

Focusing again on the objective of this series, this second part is aimed specifically at implementing the Factory Pattern, by designing a form element factory, which will be tasked with building regular form components, in this way abstracting the rendering process for each element.

Essentially, the article is intended to provide a practical step-by-step guide to apply design patterns in real world conditions, such as form design an implementation, by attending the requirements that most developers must face on a frequent basis.

Thus, it's time to go deeper into the object-oriented form generation method. Let's go!



 
 
>>> 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 1 - Follow our Sitemap

Dev Shed Tutorial Topics: