|
|
PEAR Coding StandardBut we're not religious about that... Class names reflect directory locationThe __autoload stuff only works, if the classname is equal the Directory + Filename. (of course, if you include_once the class before you call it, it doesn't matter where the class is. But this approach is not advised in our framework. It makes finding the right classes more difficult) Static Methods for creating instances of classesIt doesn't make sense every time, so it's not a must, but preferable.. Pro:
class Penguin {
{panel}
// only has to be protected, if the constructor really should not be used from outside
protected function __construct() {
// do something here
}
{panel}
static function getInstance() {
{panel}
return new Penguin();
}
{panel}
}
$pingu = Penguin::getInstance();
Minimize public API, seperate API and implementationuse the new PPP functionalityof PHP5 Use Interfaces instead of Abstract ClassesMultiple Interfaces are possible, multiple inheritance isn't Use interfaces, not classes for type hintsclass Penguin implements Fish, Bird { } class Icebear implements Mammal { {panel} //NO NO function eat (Penguin $food) { } {panel} // Better {panel} function eat (Fish $food) { } {panel} } It's much more flexible... Use lowercase fieldnames and tablenames for more compatibility
|
Add Comment