[openstack-dev] [Solum] Some initial code copying for db/migration

Christopher Armstrong chris.armstrong at rackspace.com
Mon Nov 18 21:58:19 UTC 2013


On Mon, Nov 18, 2013 at 3:00 PM, Dan Smith <dms at danplanet.com> wrote:

> Sorry for the delay in responding to this...
>
> >   * Moved the _obj_classes registry magic out of ObjectMetaClass and into
> >     its own method for easier use.  Since this is a subclass based
> implementation,
> >     having a separate method feels more appropriate for a
> factory/registry
> >     pattern.
>
> This is actually how I had it in my initial design because I like
> explicit registration. We went off on this MetaClass tangent, which buys
> us certain things, but which also makes certain things quite difficult.
>
> Pros for metaclass approach:
>  - Avoids having to decorate things (meh)
>  - Automatic to the point of not being able to create an object type
>    without registering it even if you wanted to
>
> Cons for metaclass approach:
>  - Maybe a bit too magical
>  - Can make testing hard (see where we save/restore the registry
>    between each test)
>  - I think it might make subclass implementations harder
>  - Definitely more complicated to understand
>
> Chris much preferred the metaclass approach, so I'm including him here.
> He had some reasoning that won out in the original discussion, although
> I don't really remember what that was.
>
>
It's almost always possible to go without metaclasses without losing much
relevant brevity, and improving clarity. I strongly recommend against their
use.

-- 
IRC: radix
Christopher Armstrong
Rackspace
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20131118/2b94d0bc/attachment.html>


More information about the OpenStack-dev mailing list