python - When to use class inheritance or relations? -
i'm having trouble deciding use, derived classes or many 1 relation.
for example, i'd have class of breed average data pertaining breed, , i'd have class dog individual dog data can refer breed average data. understand, can either class inheritance or many 1 relation. i'm not quite sure nuances between 2 make me prefer 1 on other.
typically, inheritance represents 'is a' relationship , composition 'has a' relationship. dog breed? not really. breed property or trait of dog, dog has breed. inheritance not appropriate in case.
Comments
Post a Comment