+ 7
Why do we use inheterances if we have dictionaries?
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 đ.
+ 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)
+ 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
+ 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đ
+ 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.
0
it's not really necessary