[TYPO3-50-general] Helping Functions

ries van Twisk typo3 at rvt.dds.nl
Mon Feb 2 14:20:49 CET 2009

On Feb 2, 2009, at 7:41 AM, Nino Martincevic wrote:

> This concept is also well-known as "virtual properties".
> The guys of EZ.no are using such things in their component framework.
> See example class below. But even without the need for get* and set*
> methods.
> Which is, by the way, in most cases an "getter/setter anti-pattern",
> sadly seen in far to many places, if used this way:

I don't think it's that sad at all.

> private $bla;
> function getBla() {
>  return $this->bla;
> }
> Why you have a getter if you set it private?
> Or why you set it private when you provide a getter?

Because you don't want people to access the variable directly.

> Use only getters when you do more then just returning the property,  
> e.g.
> calculate a value, but keep it side-effect free of course.

That's why people provide a getter, even in the case when it just  
returns a value.

So when in feature the class get's extended and the $bla get's  
calculated you are assured
that people use the interface for the class rather then access vars  
directly. A good example
is TYPO3 and extensions where extensions often get some GLOBAL and do  
You totally loose control.


More information about the TYPO3-project-5_0-general mailing list