News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

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


Lukas Smith's Blog:
Horizontal Reuse aka Traits Reloaded
March 26, 2010 @ 10:38:14

In a quick post to his blog Lukas Smith talks about the proposal for traits support that's been pending for PHP for a while now. Recent updates have been made to it, so it's come back up to the front of developer's minds:

Stefan has since tweaked the proposal and in the latest version it includes an alternative approach called Grafts along with the original Traits idea, which is essentially language level delegation pattern support. I am absolutely sure that we will either see Traits or Grafts in the next non patch release of PHP (aka 5.4 or 6.0).

Lukas would like to see the support go in sooner than later, so he requests some comments and thoughts on the proposed functionality and to leave them as comments on his blog entry.

1 comment voice your opinion now!
horizontal reuse traits rfc grafts


Marco Tabini's Blog:
5 PHP Performance Tips You Probably Don't Want To Hear
December 12, 2006 @ 13:07:38

In a new entry on his blog today, Marco Tabini introduces us to 5 PHP Performance Tips that we "probably don't want to hear".

I thought it might be interesting to write an article about the performance-enhancing tips you probably don't want to hear about - that is, those that are most likely to produce measurable (and durable) results but do require some effort on your part.

His list consists of:

  • You Don't Need To Plan Ahead In Order To Have A Plan
  • Combat Database Abuse
  • Do You Really Need A Database Anyway?
  • Scale Horizontally
  • Refactor To Scale Vertically
For each, he explains the title and gives a bit of validation to the point. There's some great mentions of tools that you can use to help accomplish them too - a profiler, the Lucene and Xapian full-text databases, and Lustre.

0 comments voice your opinion now!
performance tip plan database abuse scale horizontal vertical performance tip plan database abuse scale horizontal vertical



Community Events





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


list opinion update install package introduction deployment interview zendserver symfony framework community tips library language laravel api podcast release series

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