Home arrow PHP arrow Introducing Builder Objects in PHP 5

Introducing Builder Objects in PHP 5

In this article, the first of a three-part series, you will be introduced to the basics of creating directors and builder objects with PHP 5. As usual, there will be copious examples to help you quickly start using the builder pattern in your own PHP projects.

TABLE OF CONTENTS:
  1. Introducing Builder Objects in PHP 5
  2. Building basic XML documents: definition of the target object
  3. Of builders and XML pages: the programmatic creation process
  4. Taking control of the process: a director class
  5. Putting all the classes to work together
By: Alejandro Gervasio
Rating: starstarstarstarstar / 7
October 04, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

In PHP, as with many other trusted programming languages out there, there are many ways to establish diverse relationships between objects during the development of an application. This concept has an immediate implementation in well-known circumstances within the context of object-based programming, particularly in those cases where both aggregation and composition play a relevant role.

More specifically, if you’ve been using classes inside your PHP applications for a while, then you’ll know that there are several programming environments where a particular object isn’t completely independent. It requires the “assistance” of one or many additional objects to perform a given task.

As I expressed earlier, composition and aggregation are clear examples of well-defined object interaction, but they're definitely not the only ones that exist in the object-based universe. Even without having a thorough theory that backs you up (using only your common sense), certainly you can conceive of numerous ways for two or more objects to perform a mutual (and productive) interaction, with no need to read thick books on object-oriented programming.

Now, and particularly when using PHP 5, I’d like to introduce a concept that’s strongly related to a specific interaction between multiple objects. In this case, I’m talking about directors and builder objects, which when evaluated in conjunction, conform to what is commonly known as the “builder” pattern. But right now you’re probably wondering how the builder pattern works.

Well, to put things in a simple perspective, when the builder pattern is applied, two objects are put into action to create a third one. First, these two objects create a director; as its name suggests, the director controls all aspects of the creation process and determines what pieces and modifications will be introduced into the target object. Finally, a builder is tasked with constructing the third object in question, in accordance with particular specifications. Sounds fairly simple, doesn’t it?

Since you might have to address specific issues by applying the mentioned builder pattern eventually, in this series you’ll learn how to use it, and of course how to get the most out of it.

Are you ready to learn more on how to use directors and builder objects in PHP? Let’s get started!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: