Skip to Content
0
Jul 19, 2016 at 03:06 PM

Abstract Class and class-method

1601 Views

Hi,

I have been reading various posts on OOPS ABAP and below is the inference i have got so far.

We go for abstract classes when we have some common functions and some unique functions respective to implementing class.

Interfaces can also achieve what is mentioned above about abstract classes but we mainly go for it for polymorphism and when there is no need for common functions/global functions between implementing classes

My question is ?? what i told about abstract class can also be achieved using class-methods, class-data (for global functions) and normal class inheritance (for redefining unique functions), then why should we go for abstract classes.

Moreover, we have a disadvantage with abstract classes, that all the implementing classes must redefine all the abstract methods. We add a new abstract method to an abstract class, we need to define it in all implementing classes.

Then why are we not sticking with using class-method and normal inheritance and instead go for abstract classes?

Even interfaces have this disadvantage, but it is the only way for polymorphism.

Also, the global/common methods of an abstract class can be redefined where as class-methods cannot be, helping us achieve OO Pardigm better.

Could anyone please help me understand this, please forgive me if i am wrong anywhere.