News Feed
Jobs Feed
Sections



Recent Jobs

News Archive
feed this:

Ryan Gantt's Blog:
Horizontal reusability with traits in PHP 5.4
August 24, 2011 @ 10:42:42

Ryan Gantt has a new tutorial posted to his blog today looking at one of the features in the upcoming PHP 5.4.x releases - traits. Specifically he looks at the horizontal reusabillity they allow for in your applications.

The ability for a class to inherit from multiple parents is maligned by many, but can be a good thing in some situations. For those working in PHP, multiple inheritance has never been an option; classes are limited to one parent, though they can implement many other datatypes through the use of interfaces. Interfaces can lead to code duplication in improperly-factored inheritance hierarchies. Even in well-architected hierarchies, multiple classes that implement similar methods can contain a lot of overlap.

He starts with a definition of what traits are and where their real usefulness is (as well as what should be the difference between a class and a trait). He gives an example of a typical hierarchy where two classes extend a parent but then they both need the same functionality. Code duplication's not a possibility and inheritance make run into exposure issues. Traits come to the rescue by dropping in just the feature you need when you need it. His example code shows adding some logging to a simple class via a "Logging" trait and a "Singleton trait" example.

0 comments voice your opinion now!
horizontal reusability traits singleton logging tutorial introduction



Ibuildings techPortal:
DPCRadio Designing for Reusability
August 25, 2010 @ 09:52:53

On the Ibuildings techPortal today they've posted the latest episode of their DPC Radio podcast series (as recorded at this year's Dutch PHP Conference). This episode is Derick Rethans' talk on reusability.

This session explain a certain set of design issues for library code that either is often extended, or created with extending and inheritance in mind. There are many ways how a library can be designed to make it both easier to test, as well as for external developers to consume and use. This presentation provides techniques for doing so.

You can either listen via the in-page player or download the mp3 directly. Be sure to check out the other great episodes too!

0 comments voice your opinion now!
dpcradio podcast derickrethans design reusability dpc10



Community Events





Don't see your event here?
Let us know!


unittest framework voicesoftheelephpant testing podcast database phpunit introduction release application language conference zendframework2 opinion community development symfony2 zendframework interview injection

All content copyright, 2012 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework