Why do we use inheterances if we have dictionaries? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Why do we use inheterances if we have dictionaries?

https://code.sololearn.com/cI5TB0OHb5Ed/?ref=app

8th Oct 2018, 10:46 PM
I Am Arthur
I Am Arthur - avatar
6 Answers
+ 18
In the situation you describe here, it's better to use dictionary because it's enough for your needs. But classes are becoming useful when you want more features. Have a look at Flandre Scarlet codes, who often uses classes and does it with class 😉.
9th Oct 2018, 8:49 AM
Cépagrave
Cépagrave - avatar
+ 5
Dictionaies are useful when you deal with little amount of data compared to classes. But if you are going to make many similar objects classes play an important role. Moreover it helps to code few lines than using dictionaries. If you are using a language like lua you can completely see the difference between classes and tables(or dictionaries)
9th Oct 2018, 11:43 AM
Seniru
Seniru - avatar
+ 3
Its hard to store functions in dictionarys. It works with lambda but its not comfortable. Im not very familiar with js but the syntax of classes in js look a lot like dictionarys in python
8th Oct 2018, 11:48 PM
Tim
Tim - avatar
+ 3
of course you can do it like that, but it will be very inconvenient if you have a lot of properties for you objects for example, you make data for a person a person has: name, gender, birthday, age, nation, mate, families, friends, job, workplace, address, phone numbers, emails, google accounts, bank accounts, SoloLearn account, hobbies, dreams... with all these properties, it's very difficult to use them if you assigned them all in a list in a dictionary😃
9th Oct 2018, 10:16 PM
Flandre Scarlet
Flandre Scarlet - avatar
+ 1
Inheritance is used for taking the property of our own created method also, which is not present im the libraries or directories throughout the program. Thank You.
17th Oct 2018, 10:07 PM
NIKHIL SHEKHAR
NIKHIL SHEKHAR - avatar
0
it's not really necessary
10th Oct 2018, 7:46 PM
Ifedayo🇳🇬
Ifedayo🇳🇬 - avatar