[Grok-dev] registering a factory as a (global) utility
faassen at startifact.com
Wed Apr 25 16:03:17 EDT 2007
A fairly common pattern is the need to register a factory as a utility.
I thought that'd be just:
Unfortunately that's not the case. This registers an *instance* of Item,
as global utilities actually instantiate Item.
Now we could simply say that's wrong, and people should instantiate
That would work, and that's fine when considered in isolation, but
unfortunately that is assymetrical with local utility registration,
where we can't require this. Local utilities should only instantiate
from their factories when the object that has these utilities associated
is actually installed.
It's still useful to have this for global utilities, though. I propose
the following alternate directive to do this:
I chose a separate directive because making global_utility take either a
factory or an instance requires all kinds of extra checks and is not as
readable as having a separate directive. I'm not sure I'm happy about
the name though.
More information about the Grok-dev