News Feed
Sections
News Archive


Community Events
php|tek 2008 PHP Conference



feed this:

PHP in Action:
Public constructors considered harmful
0 comments :: posted Monday May 05, 2008 @ 10:21:33
voice your opinion now!

According to the PHP in Action blog, public constructors can be hazardous to your (application's) health and should be replaced.

Everybody who writes object-oriented code knows about constructors. You need them so the program knows how to instantiate objects, right? And you especially need them when a lot of things have to be done while instantiating an object. [...] So why would I be skeptical of public constructors?

The solution, as he sees it, is to make a "constructor" that's actually called statically with parameters that returns an instance of the class it's in as well as performing the action. He argues that this can help make the code much more readable for some types of method calls.

tagged with: public constructor harmful replace private instance


PHPBuilder.com:
Class Inheritance with PHP
0 comments :: posted Monday February 18, 2008 @ 07:58:00
voice your opinion now!

On PHPBuilder.com today, there's a new tutorial that takes a beginning look at PHP5's class inheritance model.

There are many benefits of inheritance with PHP, the most common is simplifying and reducing instances of redundant code. Class inheritance may sound complicated, but think of it this way. Consider a tree. A tree is made up of many parts, such as the roots that reside in the ground, the trunk, bark, branches, leaves, etc. Essentially inheritance is a connection between a child and its parent.

They choose to go with a "car" illustration instead and show how a child of the Product class (Car) can access the private properties of the parent. They also include an example of it in action with a bit of HTML output.

tagged with: inheritance class php5 object private protected public tutorial


PHP5 releases database cakephp zendframework package security release code framework conference ajax job zend application pecl mysql book developer PEAR

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