On 11/18/2013 04:58 PM, Christopher Armstrong wrote:
On Mon, Nov 18, 2013 at 3:00 PM, Dan Smith <d...@danplanet.com
<mailto:d...@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.

++

-jay


_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to