[Typo3-dev] divide ext code in several classes

Michael Zedeler michael at zedeler.dk
Sat Nov 1 01:05:08 CET 2003


First a disclaimer: I am not one of the Typo3 developers. Even worse: I 
am not finished with my first Typo3 project yet.

Rene Ott wrote:

> We are at the moment developing a quite big extension. Since the code is
> too much too handle this in one class we have to divide it in several.
> Now the problem:
> 
> In another class that is (like the standard pi1 class generated by the
> kickstarter) also inherited from tslib_pibase I cannot access for
> example cObj or the locallang file. In the standard pi1 class this all
> works without problems.

It sounds like your objects have been designed in a fashion that doesn't 
separate responsibilities well. Consider whether your design is right. 
There should only be one class with the responsibility of the plugin 
(thus inheriting from pibase).

Other classes can then be written for auxillary tasks, such as form 
rendering, database queries, permission checking and so forth.

I am writing a project where I have extended the pibase class to include 
some common methods used by all plugins in the project. That is the 
reverse situation of what you're talking about - it seems to work fine.

Feel free to send a link to some UML diagrams that shows your current 
class hierarchy.

> A solution is to inherit all the other classes from the standard pi1
> class but I want to have my classes as clean as possible.
> 
> What to do ? Does the kickstarter some special preparations before it
> start the standard pi1 class ?
> 
> In other extensions all the code is in the standard pi1 class, even of
> ttboard which has 5000 lines...

Writing huge classes is generally not a good idea, but you shouldn't go 
to extremes just to split your class in smaller ones.

Regards,

Michael.





More information about the TYPO3-dev mailing list