Properties | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Properties

I tried to read through the internet on why I need properties and I just don't understand when I use them and which benefit it gives me? If anyone could explain it to me I would be very grateful.

4th May 2018, 1:38 PM
Elsayed Salama
Elsayed Salama - avatar
5 Answers
+ 5
Greetings friend! There are three principles of Object-oriented programming: encapsulation, inheritance and polymorphism. When you are creating objects you have to make attributes of this object private for making your app safety. So you use encapsulation. But for accessing them you should use public functions(methods) called getters and setters. So it will be useful if u work with attributes. Happy Coding! 😊
4th May 2018, 2:00 PM
dev.Y
dev.Y - avatar
+ 2
why do you need properties?image you had no name,no property,and you were 100% like every other human on earth,how would identify you.Same thing,properties define an objects attributes,what makes it different from other objects
4th May 2018, 2:49 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 1
The main idea is use private attributes(class variables) and public functions(class methods). But if u make ur attitudes private u can't access to data so u have to use public functions.
4th May 2018, 5:08 PM
dev.Y
dev.Y - avatar
+ 1
You are not dumb because you do ask questions, That is a smart thing to do. So what is you current knowledge at this moment. Did you make a class ? (a car-class or a person-class) Did you create a object of that class ?
4th May 2018, 8:13 PM
sneeze
sneeze - avatar
- 1
Thank you guys for your answers. I don't know if I am dump but I still don't get it :(
4th May 2018, 4:13 PM
Elsayed Salama
Elsayed Salama - avatar