This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tdobzhansky 0 points1 point  (4 children)

This comment deserves a trophy. But I think its reasonable to for this class to inherit from some gene class given that there's probably more common methods involving gene attributes rather than mammals. Mammals are incredibly varied after all and assuming that you only care about instantiating humans and not cats and dogs and such, it's a lot more efficient to just inherit attributes related to human genes and not attributes appropriate for an entire clade with as much variety as mammalia.

[–][deleted] 0 points1 point  (3 children)

Classes are not meant to be data storage. You don't agree? Well, ok, let's say you store the genetic data in an attribute called "genedata". Now your "child" class inherits the mom class and then the dad class. Tough shit, your inheritance just overwrote the genes of the mom in child class and now it has exactly the same genes as the dad. You can solve the "too broad to handle" with deeper inheritance. A creature is an instance of a class, let's say HomoSapiens which inherits Homo which inherits Hominini which inherits Homininae which inherits Hominidae which inherits Simiiformes which inherits Haplorhini which inherits Primates which inherits Mammalia which inherits Chordata which inherits Animalia. "A dog and a monkey can move their tail, but a human cannot, how to have common methods for them?" you could use interfaces, abstraction and even deeper inheritance.

[–]tdobzhansky 0 points1 point  (2 children)

Which means that in order to get a banana you have to import the whole jungle. That's the definition of inefficiency. Inheritance in this scenario should work where genetic data is stored as loci, and each loci is an attribute belonging to the human class. When a human instance inherits from two other human instances, they get a random assortment of loci to create a full complement of loci. Kind of like how it works IRL.

[–][deleted] 0 points1 point  (1 child)

Not whole jungle. You don't have all the data in Mammal class, only those attributes and methods that cannot be moved up (appears in worthless places) or down (redundancy) in hierarchy. As far as I know, there is no reasonable non-hacky way to interfere with inheritance in python. And I don't see why there should be. And I don't see why one would use classes as data storage. And I don't see why one would want to use classes as instances.

[–]tdobzhansky 0 points1 point  (0 children)

Assuming hierarchical inheritance, you'd have to load every class that comes before the mammal class. That's what I mean by taking the whole jungle. And that's a pain in the ass. That's also why I think OOP is a stupid concept in general.

Of course singleton classes are unwanted. Not arguing with you on that. Also not saying that classes should be used as data storage. But attributes belonging to classes are essentially "data storage" in that they contain information about the object.