On Wed, Jan 27, 2010 at 5:52 AM, Ashley Sheridan
wrote:
> Hi All,
>
> I know that a class can only inherit from one other single class in PHP,
> but how would I go about simulating a multiple class inheritance? For
> example, if I had several small classes that dealt with things like form
> genera
2010/1/27 Ryan Sun :
> 1, you can implement multiple interfaces
>
> 2, you may want to return object instead of extending classes,
> eg.
> class Small_Class_Abstract
> {
> public function getFormGeneration()
> {
> return new Form_Generation();
> }
> }
> class Small_Class_A extends Small_Class
1, you can implement multiple interfaces
2, you may want to return object instead of extending classes,
eg.
class Small_Class_Abstract
{
public function getFormGeneration()
{
return new Form_Generation();
}
}
class Small_Class_A extends Small_Class_Abstract
{
}
$A = new Small_Class_A();
Oh, and i'd allow 1 (or _maybe_ 2) "very big" super-class(es) at the
top level of a framework / cms, that do include 50-100 smaller
classes.
"midware" classes can evolve (be extracted) from the superclass, as
your app evolves.
Try to keep groups of functions relating to as few smaller/lower
classe
If you want m-inheritance, you can "include" (encapsulate is the word
i think) your smaller classes in "midware" and "big top-level" classes
that expose (part of) their interfaces. It's easy.
But guard against creating too many dependencies between different
smaller classes to and "bigger" classes
5 matches
Mail list logo