[FLOW3-general] Object Framework vs. new
Michael Sauter
mail at michaelsauter.net
Tue Feb 23 17:08:23 CET 2010
On 22.02.10 11:18, Robert Lemke wrote:
> Hi folks,
>
> as a general rule of thumb for those not developing the FLOW3 core itself but your very own packages:
>
> - Use "new" only in your unit tests, or when instantiating Exceptions.
> - Use Dependency Injection whenever possible for retrieving singletons.
> - Use create() for instantiating prototypes
>
> If you use "new" instead of FLOW3's functions,
>
> - you won't get dependencies injected
> - you won't get automatically built AOP proxy classes
> - FLOW3 cannot manage the singleton or session scope of that object
> - the security framework doesn't know / care about your object
> - your object cannot be persisted
>
> For the Reflection Service the case is a bit different because it is part of the FLOW3 core. With hen and egg problem we are referring to the challenge that the Reflection Service must be available even before the Object Framework is initialized. But these special cases really only occur in the FLOW3 package.
>
> One remark at last: In alpha 8 you'll see a heavily refactored Object Framework which comes which a big speed gain. And while working on it, I took the (probably last) chance to slightly clean up the API again: There won't be an Object Factory in the future (but it'll stay there for two versions, for backwards compatibility). Instead you'll only have the Object Manager which provides these two important methods:
>
> create($objectName, $argument1, $argument2, ...)
> get($objectName)
>
> Note that create() moved from the Object Factory to the Object Manager and that getObject() is now simply called get().
>
> But don't worry about that yet - with the release of alpha 8, I'll post further information, including a little script for migrating (most of) your existing code.
>
> Cheers,
> robert
Thank you very much for the detailed explanation!
More information about the FLOW3-general
mailing list