+ 2
Object and classes vs functions
What's the difference between function and object & classes ?? And why it is recommended or important to use oops concept??!
1 Réponse
+ 5
Function is a block of code to execute
Object is a variable represent something that can hold value and do something
Class is the structure/blueprint of an object
Sometimes you'll encounter problem like you need multiple value for each of variable. For example a person with name and age.
Without oop you'll need to do this
name=["a","b"]
age=[18,28]
Then identify each person's age using match index, what if there are more than 10 attribute ? Write 10 array ? What if more ? It'll get harder and harder.
In OOP, you only need 1 array of an object, but it covers every variable the person need to have
person[6].age