‎2008 Feb 06 10:04 AM
Hi,
Can any one explain with a simple example what you mean by
class,subclass,superclass...
Thanks & regards,
Alex.
‎2008 Feb 06 10:13 AM
If A is a subclass of B, then B is the superclass of A.
A class is an encapsulation of a concept, perhaps some physical object like a vehicle, or a business object like a purchase order, or something more abstract like BW start routine. A subclass is more specific than its superclass. A superclass is more general than its subclasses. ( In ABAP a class can have up to one superclass, though type OBJECT can be considered a superclass of all classes, except itself ).
For example, you may have a class representing VEHICLES. It could have two subclasses CAR and BICYCLE. ( So VEHICLES would be the superclass of both CAR and BICYCLE ). The class VEHICLES would have all the attributes and methods that apply to all kinds of vehicles - e.g. "source of power". The CAR class would inherit all the VEHICLE attributes and methods, and have additional methods and attributes applicable only to cars - e.g. "number of doors". Similarly for the BICYCLE, you might have "pedal_type". Both CAR and BICYCLE would have "source of power", as they've inherited this from VEHICLES.
matt
‎2008 Feb 06 10:13 AM
If A is a subclass of B, then B is the superclass of A.
A class is an encapsulation of a concept, perhaps some physical object like a vehicle, or a business object like a purchase order, or something more abstract like BW start routine. A subclass is more specific than its superclass. A superclass is more general than its subclasses. ( In ABAP a class can have up to one superclass, though type OBJECT can be considered a superclass of all classes, except itself ).
For example, you may have a class representing VEHICLES. It could have two subclasses CAR and BICYCLE. ( So VEHICLES would be the superclass of both CAR and BICYCLE ). The class VEHICLES would have all the attributes and methods that apply to all kinds of vehicles - e.g. "source of power". The CAR class would inherit all the VEHICLE attributes and methods, and have additional methods and attributes applicable only to cars - e.g. "number of doors". Similarly for the BICYCLE, you might have "pedal_type". Both CAR and BICYCLE would have "source of power", as they've inherited this from VEHICLES.
matt
‎2008 Feb 06 2:02 PM
hi,
That is the concept called Inheritence in OO Programming.
INHERITANCE
Inheritance is an implementation relationship between classes that allows a class, called a subclass, to inherit all components of another class, called a superclass. In ABAP Objects, adding INHERITING FROM to the class definition statement enables inheritance .
In a subclass you define additional components or redefine instance methods that were inherited from the superclass, but you can't remove inherited components. Therefore, a subclass is strongly coupled to its superclass just by containing all of the superclass's components. While a subclass knows its superclass, a superclass has no knowledge of its subclasses. Nevertheless, the semantic coupling is strong in both directions because changing a superclass automatically changes or even invalidates all of its subclasses.
While a subclass specializes a superclass by adding components or redefining methods, a superclass is a generalization of its subclasses. In fact, inheritance should be used to implement relationships between classes that can be described in terms of generalization and specialization. For example, if you compare a passenger_airplane class to a cargo_airplane class, you will find that many common features can be put into a general superclass, airplane.
Hope you got something out of the explaination.
regards,
theja
‎2008 Feb 07 4:22 AM
Hai.
check the links.
http://help.sap.com/saphelp_nw70/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f54127111d3b9390000e8353423/content.htm
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html
http://abapprogramming.blogspot.com/2007/10/oops-abap-15.html
regards.
sowjanya.b
‎2008 Feb 07 5:12 AM