Is anyone using meta-meta-classes / meta-meta-meta-classes in Python/ other languages?

前端 未结 5 630
北荒
北荒 2020-12-14 20:25

I recently discovered metaclasses in python.

Basically a metaclass in python is a class that creates a class. There are many useful reasons why you would want to do

5条回答
  •  时光说笑
    2020-12-14 20:54

    This reminds me of the eternal quest some people seem to be on to make a "generic implementation of a pattern." Like a factory that can create any object (including another factory), or a general-purpose dependency injection framework that is far more complex to manage than simply writing code that actually does something.

    I had to deal with people intent on abstraction to the point of navel-gazing when I was managing the Zend Framework project. I turned down a bunch of proposals to create components that didn't do anything, they were just magical implementations of GoF patterns, as though the pattern were a goal in itself, instead of a means to a goal.

    There's a point of diminishing returns for abstraction. Some abstraction is great, but eventually you need to write code that does something useful.

    Otherwise it's just turtles all the way down.

提交回复
热议问题