Advantages of using inheritance
Using inheritance has a number of advantages:
-
When you change the ancestor window, the changes are
reflected in all descendants of the window. You do not have to
make changes manually in the descendants as you would in a copy.
This saves you coding time and makes the application easier to
maintain. -
Each descendant inherits the ancestor’s scripts, so you do
not have to re-enter the code to add to the script. -
You get consistency in the code and in the application
windows.
When you use inheritance to build an object, everything in the
ancestor object is inherited in all its descendants. In the
descendant, you can:
-
Change the properties of the window
-
Add controls to the window and modify existing
controls -
Size and position the window and the controls in the
window -
Build new scripts for events in the window or its
controls -
Reference the ancestor’s functions and events
-
Reference the ancestor’s structures if the ancestor contains
a public or protected instance variable of the structure data
type -
Access ancestor properties, such as instance variables, if
the scope of the property is public or protected -
Extend or override inherited scripts
-
Declare functions, structures, and variables for the
window -
Declare user events for the window and its controls
The only thing you cannot do is delete inherited controls.
If you do not need an inherited control, you can make it invisible
in the descendant window.