Object Interaction in PHP: Introduction to Aggregation, part 1

Aggregation in PHP allows one object to use another object. It's a very powerful concept. This article, the first in the series, serves as an introduction to some of the things you can do with aggregation.

Introduction

In the growing world of Object Oriented Programming, the ways that objects interact with each other involve directly working with several concepts that deserve an in-depth look, in order to take advantage of their power in real-world applications. Particularly when we're dealing with PHP, which is definitely an easy-to-grasp language compared to the harder learning curves of Java or C++ (among others), things are a lot more accessible, even if we go beyond the limits of working with procedural solutions.

At this point, most PHP users have already experienced the nice capabilities of PHP classes, by taking either the do-it-yourself road or reusing existing, well-trusted classes for managing larger projects. However, there are times where we need to work with several classes that require a strong interaction to efficiently accomplish a given set of tasks. So, this relationship immediately brings up a question: how do objects interact? Fortunately, the answer is quite straightforward, since this interaction can be defined within well-known OOP pillars.

The first trusted friend is inheritance, which offers a powerful mechanism for building class hierarchies, and allows us to address specific issues in a number of subclasses without the need to recreate the logic or functionality that already exists in the super class or parent class. That sounds very familiar, doesn't it?

Chris Charlton

Chris CharltonChris, Los Angeles' CSS & ActionScript guru, successfully cannonballed into web development in the late 90's. Always caught up with the latest in Flash, Dreamweaver, Fireworks, and XML, Chris authored premium articles for the largest Dreamweaver/Flash community (www.DMXzone.com) and produced WebDevDesign (iTunes featured), a popular Web Design & Development Podcast. Somewhere, Chris finds time to run an authorized Adobe user group focused around open source and Adobe technologies. Being a big community leader, Chris Charlton remains a resident faculty member of the Rich Media Insitute and lends himself to speak at large industry events, like JobStock, NAB, and FITC Hollywood.

Brain cycles from Chris are always Web Standards, Flash Platform, and accessibility.

See All Postings From Chris Charlton >>

Comments

Be the first to write a comment

You must me logged in to write a comment.