|
Classes and Objects are building blocks of any OOP language. An entity from a real world is mapped as class in programming language. A class is an abstract representation of real object in real world. Technically, a class is a package that contains some data and defines some methods that can be performed on that data. A class has an interface and a structure (data) also. The interface describes how the object of a class interacts with the outer world, while the structure represents the data format. Confused .. Okay lets understand by an example.. Consider a human being named 'Neo'. Neo has a pair of eyes, ears, hands, legs, nose, brain and many other parts. And what can Neo do ? He can Kick, Jump, Fly and do many other things. now if you had to map this into a computer program how would you do it ? There could be many ways you can do it. But the best would be with OOP. So in this case we create a class called 'Human' whose attributes are eyes, ears, hands, legs etc. and methods are kick, fly, jump etc. Now lets say Neo is not alone, we have Morpheus also. So Morpheus becomes another instance of the same class 'Human' (because Morpheus also has eyes, ears etc and he can also kick, fly and jump). Thus I can have many more instances of Human as Trinity, Cypher etc. From this example we explained: - A class is an abstract representation of a real object in real world
- A class encapsulates data (hands, legs) and its methods (kick, fly) also.
- A new object with same functions and features is just an different instance (Morpheus and Trinity) of the same class
Simple right  In the next chapter we will learn how to create class and instantiate its object in ABAP.
|