[Catalyst] plugins; was Re: debug mode
mla
maurice.aubrey at gmail.com
Thu Jun 7 23:12:10 GMT 2007
Matt S Trout wrote:
> On Thu, Jun 07, 2007 at 01:04:02PM -0700, mla wrote:
>> Other than the fact you don't like the style, why is it bad?
>> You don't like singletons?
>
> I'm not fond of any magic global if I can possibly avoid it - I find it
> tends to encourage tight coupling of code and action at a distance and
> makes testing and debugging messy.
But if you are going to use ACCEPT_CONTEXT then you are tightly
coupling the model to the application.
I agree that should be avoided... but they are equivalent if not
more tightly coupled by adding the context to the actual model instance.
I'm not sure about the "action at a distance' thing. Also seems pretty
equivalent. You have this outer context thingy making a call into a
magical model method so it can add a singleton to itself. ;-)
In terms of testing, seems like the singleton is a bit better since you
have no ACCEPT_CONTEXT method to test.
I don't see how debugging would be any harder.
> I prefer anything a method call needs to have been either (a) passed to the
> object when it was constructed or (b) passed to the method as it's called.
>
> It can be a bit more work up-front but it makes you think about your
> architecture, which I find pays off down the road.
A method call could also need to have access to other modules/packages
it will delegate to. The singleton seems equivalent.
I agree that having the singleton does make it easier to couple too
tightly though.
More information about the Catalyst
mailing list