[TYPO3-dev] SOLUTION (?) : Multiple XCLASS inheritance

Edwin de Jong g.e.dejong at student.utwente.nl
Thu Feb 9 01:24:52 CET 2006


Op woensdag 08 februari 2006 22:41, schreef Elmar Hinz:

> I think you are both right in your own way. In the world of JAVA the
> interface that needs to be implemented by inherited classes is a very
> usefull concept. It gives a lot of flexibility if you can rely on and work
> with cleanly implemented interfaces. You quickly can exchange one class
> against another. Interfaces are the basicle principle of the AVALON
> framework.
>
> On the other hand  -- I think that is the concern of Kasper -- large
> hierarchies of inherited classes often tend to make development tenacious.
> Combining a few readymade components is done more quickly then implementing
> new features into a inheritd class.

I do agree with Kasper as well. Inheritence is a useful tool, but IMHO it 
should not be overused. Its all too easy to define a class for this and 
another one for that, but it will create a large forest which in the end is 
only clearly understood by experts. Keep things shallow and use design 
patterns for solving larger tasks (see interfaces as a structure for 
templates).

One of the reasons why I think Typo3 is good in what it does is that it 
effectively defines a network of interrelated functionalities combined with a 
very simple glue (TypoScript). The simpler the glue, the easier it gets to 
add new ideas and spur creativity.

Using hooks (or better even: events) will solve this problem in a simple way. 
It keeps the hierarchy shallow, and it allows for structures like this:

function foo($event) {
  if ($event->type = type_i_like) {
    process...
  } else {
    parent::foo($event);
  }
}

greets,

Edwin




More information about the TYPO3-dev mailing list