deference between inheritance. 1-using decorator 2-class child(parent) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

deference between inheritance. 1-using decorator 2-class child(parent)

tow type of inheritance. what's deferent?

25th Aug 2016, 5:47 PM
Ahmed chiboub
Ahmed chiboub - avatar
2 Answers
+ 1
decorators are NOT used for inheritance, only for adding functionalities to functions
30th Aug 2016, 10:03 PM
Amaras A
Amaras A - avatar
0
The decorated function is not related to the decorator function, while the inherited function is related to the function it inherits from. Think of it from this point of view: if you delete the parent class, all the child classes will suffer, because the parent class methods and properties are essential to the child classes existence. In some way, decorator is more like clothes. If you delete the decorator function, all the decorated functions will just become 'naked'. It won't go unnoticed, however, the functions themselves will continue to function. Here is an explanation of the decorator usage: https://code.sololearn.com/cD09ijlIS6Ev/?ref=app
7th Jun 2018, 2:31 AM
Denys Yeromenko
Denys Yeromenko - avatar