Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Objects and classes

Former Member
0 Kudos
83

Hi All

I am new to ABAP Objects and i feel lil difficult to under the concept and classes..can any one please give me with small example to easily understand about the tole of objects and classes..

Thanks and Regards,

Arun joseph

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
54

Simply put, classes are definintions, and an object is an instance of that definition. So you define your class, and you can then have multiple instances of that class, which we refer to as objects of the class. So say you have a class called "Cat", you define this class with an attribute called "color". Now we know that you can have more than one cat, so you create an object of the class Cat, and you an assign the color as black, you can then create another object of the class Cat, and set the color as white. Do you see the concept?

Regards

Rich Heilman

0 Kudos
54

Yeah thank you so much Rich..Could you please help me out with the same logic what you have explained for Encapsulation,polymorphism and Inheritance?

Thanks and Regards,

Arun Joseph

0 Kudos
54

Encapsulation refers to how classes encapsulate data. For example, I mentioned attributes in my previous post. These attributes define data or variables inside the class, which depending on the visibility can not be accessed outside the class.

Regards,

Rich Heilman

0 Kudos
54

Hello,

Take a look on this: [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15].

Regards.

0 Kudos
54

Inheritance is another basic OO concept, where you have a relationship between two or more classes. Say for example, we have a class called Animal, which has some attributes which are common for all animals, such as height, weight, max speed, etc. This will be our "Super" class. Next we have another class called "Tiger" which inherits from the class Animal. So these means that the Tiger class would have the same attributes as the Animal, and might have some additional attributes specific to a tiger which are defined in the tiger class, such as "number of stripes". So when you create an object of a tiger, you will have access to the attributes of the tiger as well as the animal. This is the most basic example of inheritance.

Regards,

Rich Heilman

former_member230674
Contributor
0 Kudos
54

Hi arun,

These are very simple concepts.There is no need to worry about it.

Object is an instance of a class.Class is an abstract description of an object. Class is a set of instructions that is used to build an object. Class represents properties of an object.

eg: Vehical, Car,Bird,Box,Student

Object represents a properties of real time entity like

engine, color,marks, legs,height,width etc.

The following links provide more information with examples.

Link:[http://help.sap.com/saphelp_nw70/helpdata/EN/c3/225b5c54f411d194a60000e8353423/frameset.htm]

Link:[http://help.sap.com/saphelp_nw70/helpdata/EN/c3/225b5c54f411d194a60000e8353423/frameset.htm]

if any more doubts, come to me with your doubts.

if it useful, reward points.

Thank you,

Prasad G.V.K

Former Member
0 Kudos
54

Former Member
0 Kudos
54

consider one Game is class...

now 8 ppl want to play same game at time.. so we dont need to load game 8 times...

instead just make 8 copy call object which can share game and played by all 8 ppl.