 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: Subtype Polymorphism - Swapping Implementation at Runtime
by Chris Cornutt September 17, 2012 @ 12:48:52
On PHPMaster.com there's a new tutorial from Alejandro Gervasio about subtype polymorphism. It sounds a little scary, but really it's just a look at sub-objects that inherit from parents and how to swap them around at runtime to do different things.
In this article I'll show you how to exploit the virtues that Polymorphism offers through the development of a pluggable cache component. The core functionality can be expanded later to suit your needs through the development of additional cache drivers.
He starts off with the definition of an interface to provide structure to the sample application (the CacheInterface) and implements it in two different subtypes - a FileCache and an AppCache (using the file system and APC, respectively). He builds on these and creates a "View" that uses these caching systems to generate and save the output to a cache for use later in the execution.
voice your opinion now!
subtype polymorphism tutorial interface abstract caching
PHPBuilder.com: Implementing the Singleton Pattern in PHP 5
by Chris Cornutt November 24, 2010 @ 13:44:13
If you haven't taken much of a look at design patterns and how they can help your development life, the Singleton pattern is a good place to start. On PHPBuilder.com there's a new tutorial introducing this handy pattern and how it might fit your needs.
One of these patterns is the Singleton design pattern, which is based on the mathematical concept of a singleton (a set with a single element). [...] Sometimes the Singleton pattern can help complete important programming tasks, but only you can decide where and when it fits your needs. As a pointer, the Singleton pattern fits well when you manage a shared resource [...] because your application should have only a single instance in order to avoid conflicting requests for the same resource and to minimize performance issues.
He shows an example of how to implement it, first as a class template and then in actual use (complete with code ready to copy and paste). He also shows how you can use the singleton pattern to act as a frontend to other classes, making a sort of polymorphism simple. Thankfully, he also explains some of the risks in using this design pattern and that "less is more".
voice your opinion now!
singleton designpattern tutorial polymorphism
NETTUTS.com: Understanding and Applying Polymorphism in PHP
by Chris Cornutt September 09, 2010 @ 11:13:37
On the NETTUTS.com site today there's a new tutorial by Steve Guidetti about understanding and handling polymorphism in PHP - making interfaces to multiple objects that all work the same way. In this tutorial he gets more in depth and includes some code to illustrate.
In object oriented programming, polymorphism is a powerful and fundamental tool. It can be used to create a more organic flow in your application. This tutorial will describe the general concept of polymorphism, and how it can easily be deployed in PHP.
He explains to concept of polymorphism for those that haven't seen it before - common interfaces to multiple objects - and how to can help make using the parts of your application much simpler. In his code examples he uses interfaces and abstract classes to make the connections. The interfaces define the structure to follow and the abstract classes are the multiple objects that must follow it.
voice your opinion now!
polymorphism tutorial interface abstract class
DevShed: Polymorphism, Design Patterns, and PHP Programming
by Chris Cornutt October 05, 2006 @ 10:32:00
DevShed is continuing on with their series looking at advanced concepts of object oriented PHP with this new tutorial. It's part three of four parts, looking this time at polymorphism and design patterns in PHP.
Last week, we continued our discussion of the object-oriented features of PHP 5 by taking a first look at design patterns. This week, we will continue looking at design patterns, and examine polymorphism. This article, the third of four parts, is excerpted from chapter two of the book Advanced PHP Programming, written by George Schlossnagle.
They cover some of the more handy features OOP in PHP5, including interfaces, type hinting, the factory pattern and the singleton pattern.
voice your opinion now!
tutorial polymorphism design pattern programming singleton interface factory tutorial polymorphism design pattern programming singleton interface factory
DevShed: Using Inheritance, Polymorphism and Serialization with PHP Classes
by Chris Cornutt August 15, 2006 @ 09:02:43
Some concepts of object-oriented design are harder to figure out that others for a budding programmer. Thankfully, there's articles like this one from DevShed to help fill in some of the gaps. Specifically, they focus on inheritance, polymorphism, and serialization in your PHP classes.
If you are working with classes in PHP, you will sooner or later encounter inheritance, polymorphism, and serialization. The ability to use these three will help speed up your code writing. This article covers how to use them, and more.
First off, they look at inheritance and working with child classes before moving on to polymorphism (similar functionality, different objects), calling functions statically, and serializing objects to make passing them around much easier.
voice your opinion now!
classes object oriented polymorphism inheritance serialization tutorial classes object oriented polymorphism inheritance serialization tutorial
DevShed: PHP 5 and Polymorphism
by Chris Cornutt March 07, 2006 @ 07:19:08
From DevShed, there's a more advanced tutorial that might interest PHP developers out there looking for more info on "polymorphism" for their apps.
This article explains what polymorphism is and how it applies to object oriented design in particular. It also explains the pros and cons of polymorphism when working with certain versions of PHP.
They start with a definition on the topic that doesn't seem to help much: "The occurrence of different forms, stages, or types in individual organisms or in organisms of the same species, independent of sexual variations." They do, however, follow that with what it means to programming: "...an interface or base class without regard to an object's concrete class." They also include a simple example (no code, that's later).
With that concept in place, they move to the next step - working with the example to create code that can be used as a reference point. They talk about using a switch to make the script respond differently to different inputs and the lack of "late binding" support in PHP5.
voice your opinion now!
php5 polymorphism late binding switch php5 polymorphism late binding switch
|
Community Events
Don't see your event here? Let us know!
|