Introduction to OOPS
OOPS - object oriented programming language.
1. Class - Collection of objects (methods, attributes).
2. Types of classes.
* Global class - SE24(class builder), we can reuse the global class.
* Usual ABAP class - Its purpose is to write the logic (function module).
* Exception class - Its purpose is to raise and handle the exception.
* Persistence class - Its purpose is to perform database operations (Insert,Update,Delete).
* Unit test class - Its purpose is to write unit test cases.
* Local class - Access within program only.
3. Levels of method.
* Instance method - we need to create a object to call that method.
- Instance attribute accessed only using object.
-> Instance method
* Static method - There is no need to create a object.
- Static attribute accessed using class & object.
=> Static method
4. Visibility
* Public - We can access the public components within the class as well as outside the class.
* Protected section - We can access the protected components within the class as well as derived or child class.
* Private section - We can access the private components within the class only.
* In ABAP we haven't default visibility section.
5. Types of parameters.
* Importing - Input
* Exporting - Output
* Changing - Input/Output
* Returning - A method can have any number of exporting and changing parameters, but returning is always one.
6. Object - Instance of class.
7. Inheritance - One class get the properties of another class.
* The sub class can access the all the components of super class which are defined under public or protected section only not under the private section.
* Through super class object we can access the components of the super class only.
* Through sub class object we can access the components of sub class as well as super class also.
* Actually, Multiple inheritance isn't possible.
If we want Multiple Inheritance, then we can do through interfaces only.
Directly it's not possible.
8. Polymorphism - A single entity or method behaves in multiple forms then it's called Polymorphism.
- For example, take VBELN
it acts as Sales document number in VBAK table.
it acts as Delivery number in LIKP table.
it acts as billing number in VBRK table.
VBELN is only one variable act as 3 types in 3 different tables.
9. Encapsulation - Binding or wrapping the code and data in a single unit is called Encapsulation.
Comments
Post a Comment