[TYPO3-50-general] Magic Get too magic?

Elmar HInz elmar.hinz at team.MINUS.red.DOT.net
Fri Feb 23 09:38:26 CET 2007


>    TYPO3::getInstance()->getComponentManager()->...
> 
>    TYPO3::getInstance()->componentManager->...
> 

Hi,

in Java I have learned never to access object variables directly, but
always to access them by getters/setters.  

I like this:

A.) Plain setters/getters that don't manipulate values:

 They are named get/set.

 1.) Generics:

   $this->get('someVariableName');
   $this->set('someVariableName', 'someValue');

 2.) Named setters/getters:

   $this->getSomeVariableName();
   $this->setSomeVariableName('someValue');

B.) Setters/getters that perform some action like instantiation, loading,
    transformations etc.:

  They are named but by their performing action, to document what they do.

  $Class = Factory::findService('SomeService');
  $T3 = TYPO3::findIt() ...   or  $T3 = TYPO3::makeIt() ...
  $variable = $this->loadSomeVariableName();
  $this->importSomeVariableName($value);

Regards

Elmar













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