3 ms·
In my case, I'm using Django on several projects. It uses inheritance to implement the ORM, the views, filters, etc. etc. When you say "there are virtually no
by Ensorceled 5y ago
In my case, I'm using Django on several projects. It uses inheritance to implement the ORM, the views, filters, etc. etc.
When you say "there are virtually no valid uses of (implementation) inheritance" ... how do you expect the thousands of us using Django to respond to that? A link to the Django framework? To defend Django? What is the point?
You're right, maybe python's object model could have instead been implemented like Go's struct but it wasn't.
- formerly_proven 5y agoIMHO there's quite a difference between what's technically inheritance in an ORM (I am assuming you mean writing "class MyModel(orm.model):", not in-database-inheritance) and Java'esque tree hierarchies of classes. The former is mostly about invoking a type operator / metaclass [1] to construct a model class from your declarative specification. I don't know what the latter is about. I think deep inheritance (where deep means like "more than 2") are virtually always a mistake. Stuff like toolkits that go Object>Widget>AbstractButton>PushButton might be an exception but I'm not entirely sure, there's probably a better way. [1] I think metaclasses aren't type operators in the strict sense, because they're not handed a finished type, but rather the declaration of a type, and then create a type. Maybe there's a word for that.
- throwaway894345 5y agoI don't know enough about Django's API to speak intelligently, but I have 15 years of Python experience and (except when APIs require it) it's perfectly easy to write Python code without using inheritance (and your code base will be better because of it). If Django or whatever requires using inheritance, you have my sympathy, and I'm not arguing that you should go to great lengths to avoid it--I'm arguing that from a language design perspective inheritance is a mistake.
- Ensorceled 5y agoAnd yet here I am being productive.
- throwaway894345 5y agoAnd I’m sure whoever told you that you couldn’t be productive in spite of inheritance feels ashamed. I hope they see this post!
- Ensorceled 5y agoI see why you use a throwaway account.
- throwaway894345 5y agoI’m not brave enough to use my legal name, unlike you Mr. Ensorceled.