[TYPO3-project-seminars] private methods and variables

Oliver Klee typo3-german-02 at oliverklee.de
Thu Nov 19 18:22:04 CET 2009


Hi Dimitri,

Dimitri Kšönig schrieb:
> I have to develop some special features for a customer and for that i'm
> using some hooks. I love hooks because it's so easy to implement
> features very fast. Normally it's easy and fast in every extension but
> seminars makes it very difficult to accomplish all i want because so
> many methods and variables are private. To go around this i have to use
> xclasses which results in much more code that is not necessary.
> 
> So: what about changing almost all methods and variables to public ones?

A basic rule of data encapsulation is that member variables of objects
should never be accessed directly, but only through accessors (getters
and setters, or not accessed at all, but only used internally).

As for the methods, we're in the process of moving the code out of the
huge pi1 class (which had only internal use for the functions) into
separate classes which have some public functions.

Generally, we try to make only these methods public that are intended
for usage from outside the object. If we made every method public, that
would practically force us to maintain this as a public API and not
allow us to easily refactor this.

However, I agree that the extensibility of the extension's classes can
be improved.

Maybe you can describe what kind of access you need for your project so
we can find a clean and maintainable way for this?


Oliver


More information about the TYPO3-project-seminars mailing list