I know App::uses
does lazy-loading, but if we are going to use i.e. CakeTime
in a small part of our code (like inside an if statement that is called 1/3 of the times the method is called) then what would be the best place to put App::uses('CakeTime', 'Utility')
?
The options are:
- AppController
- MyController
- MyController::methodName
- MyController::methodName inside the if statement (where it is actually going to be used).
I'm putting it in 4 as I guess there must be some obvious overhead (even if really small) but I don't see any reason for it to be present in every call of the controller. My colleague says 2 because it "we might need it elsewhere in the future and it lazyloads so it's not a problem". My answer to that is that if we need it elsewhere then we should redefine then where to put it according to the case.
What is your opinion and why?