HomePHP Working with Strings and the Composite Pattern in PHP 5
Working with Strings and the Composite Pattern in PHP 5
Are you a PHP developer who wants to improve your skills in pattern-based programming in PHP? If the answer to this question is an emphatic yes, then you should begin reading this article now! Welcome to the final part of the series “Implementing the composite pattern with PHP 5.” Comprised of two instructive tutorials, this series walks you through the basic concepts of this important design pattern, and shows you how to apply it with some educational examples.
Before I move forward and tell you about the topics that I plan to cover in this final installment of the series, first I’d like to revisit briefly the concepts deployed in the preceding article. This will give you a better idea of how both tutorials are linked to each other.
As you’ll certainly remember, in the first part of the series I introduced the foundations of the composite pattern, and also explained in detail how it could be applied. To quickly review its theoretical definition, in the composite pattern, one object or a set of objects will behave similarly across an application, regardless of the context where they will be used.
Of course, bearing in mind that the previous definition is in fact quite confusing, I demonstrated the application of the pattern in question by setting up a testing example. The example showed how two different file reading classes were able to generate nearly identical outputs, regardless of whether they used one or multiple file handling objects.
However, I believe that the example that I mentioned previously isn’t good enough to give a reader a decent background on how this pattern works. Thus, since this series is aimed at mastering the basic concepts of the composite pattern, in this final article I’m going to demonstrate how to use it to handle strings of data.
By the end of this article, you should have a more solid foundation on how to apply the pattern in question as part of your own PHP applications.
With the preliminaries out of the way, let’s continue learning more about the composite pattern. Let’s get going!