[TYPO3-core] Wrapper methods around globals?
Christian Kuhn
lolli at schwarzbu.ch
Wed Mar 19 17:40:42 CET 2014
Hey.
On 03/19/2014 11:42 AM, François Suter wrote:
> Now Kay Strobach thinks this should not be done for performance reasons.
> Do we have guidelines about this?
I'd suggest to use common sense as guideline ... in general I'm not
willing to sacrifice code beauty because of performance reasons. This
should only be done if you are handling a code section that is called
insanely often where code uglyfication gives us a real and measurable
benefit. Not implementing a method because one is afraid of the overhead
of doing an additional function call ... hey, this is PHP, not
assembler! A single function call during some operation just does not
matter.
In this special case, the toolbarItem class is (afaik) only called if
you really use the button, the wrapper method is nice for several
reasons (type hinting in ide, easier mocking) and we've done that at
several places already for exactly these reasons. If you think it looks
better with a local variable, then do that, too. Other good candidates
for these wrapper methods are usually TYPO3_DB and LANG.
My 2 cents
Christian
More information about the TYPO3-team-core
mailing list