Hey... Welcome to another episode of OOP with c++ post series. Today we are going to talk about very important topic in OOP. That is objects. What are objects? Why we want them.
What are objects? Well objects are the real world things. Vehicles (Cars , bikes..etc) , Tools or instruments , humans , animals all those things we can consider as objects in OOP.
How objects are described or what are the components of objects? Well if we take car as the example, It has wheels, engine, seats,... etc. And it can be move or drive. If we take human as object he or she has a name, body parts, age, .... etc, and he or she can talk , walk, eat...etc.
So the list goes on. What we can take from above examples is that objects have two major components.
An object has,
1. Properties (State , Attributes)&
2. Behaviors (Methods) .
For a car, wheels, number of seats,engine are it's properties. Driving is a behavior which belongs to car object. For humans, name,age,body parts are the properties and walking talking eating are the behaviors. I think you get the idea right! Properties means the things that belongs to an objects and behaviors are the things that objects can do... easy right!!
Did you know ?
Although most of the Programming languages can be use to OOP and also for procedural programming(Normal Programming ;) ) . Java is known as a Pure Object Oriented Programming Language....
Abstraction.
There is another important concept which is used in OOP called abstraction. What is abstraction.? When creating objects in a program we have to consider about the properties and behaviors of objects. If we consider a certain object it has so many properties and also it has so many behaviors. This is a trouble when creating objects. So instead of considering all the properties and behaviors of object we consider only on properties and behaviors which are important to us.
For example If we take car as the object and imagine you are a car sale owner. What are the properties most important to you in a car. Brand , Model , Engine capacity, top speed , price...etc. List goes on with normal things to promote the car. But instead of that list of properties there might be thousands of other properties to that car. But, they are useless for us car salesman s. So what we do is omit all the unnecessary properties and behaviors and consider only on the ones important. This scenario is called Abstraction in OOP.
In object-oriented programming, abstraction is one of three central principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.
Ok..!!! So we learned about two major concepts in OOP today. I'm hoping to talk and also use these concepts within programs.. Keep in touch.. C U in my next post.. Bye.. :)
For a car, wheels, number of seats,engine are it's properties. Driving is a behavior which belongs to car object. For humans, name,age,body parts are the properties and walking talking eating are the behaviors. I think you get the idea right! Properties means the things that belongs to an objects and behaviors are the things that objects can do... easy right!!
Did you know ?
Although most of the Programming languages can be use to OOP and also for procedural programming(Normal Programming ;) ) . Java is known as a Pure Object Oriented Programming Language....
Abstraction.
There is another important concept which is used in OOP called abstraction. What is abstraction.? When creating objects in a program we have to consider about the properties and behaviors of objects. If we consider a certain object it has so many properties and also it has so many behaviors. This is a trouble when creating objects. So instead of considering all the properties and behaviors of object we consider only on properties and behaviors which are important to us.
For example If we take car as the object and imagine you are a car sale owner. What are the properties most important to you in a car. Brand , Model , Engine capacity, top speed , price...etc. List goes on with normal things to promote the car. But instead of that list of properties there might be thousands of other properties to that car. But, they are useless for us car salesman s. So what we do is omit all the unnecessary properties and behaviors and consider only on the ones important. This scenario is called Abstraction in OOP.
In object-oriented programming, abstraction is one of three central principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.
Ok..!!! So we learned about two major concepts in OOP today. I'm hoping to talk and also use these concepts within programs.. Keep in touch.. C U in my next post.. Bye.. :)
No comments:
Post a Comment
“What do you think about this?”
“Do you agree?
Share your thoughts in the comments below!”