10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Create a User ClassHow You Can Use PolymorphismBecause permanent and temporary employees do not share identicalattributes, and because different business rules apply, their hiring processesdiffer. For this reason, the Hire method, defined in a general way for theEmployee superclass, is modified at the subclass level to handle additionalattributes defined for each subclass.Moreover, because OpenROAD allows polymorphism, you can write a methodfor a subclass that builds on the functions of a method of the same namedefined for the superclass. For example, the Employee user class defines aHire method that contains functions common to all of the subclasses ofEmployee:• Provides a hire date• Provides a unique employee number• Inserts information about the new employee into the database• Checks for errorsEach of the subclasses of Employee modifies the Hire method to its specificneeds:• TempEmployee ensures that a termination date is provided at the time ofhire and supplies a termination reason• PermanentEmployee inserts the following information into the database:– NextReviewDate– VacationDays– InsurancePlan– Bonus_temp (null if the new employee is not a manager)• Manager provides a BonusRateThe MethodExec system class defines the SendSuperclass method to facilitatethe process of supersedence. The SendSuperclass method invokes thesuperclass's version of the current method, avoiding the need to repeat thecode in the subclass's method.The SendSuperclass can be invoked only on the CurMethod system variable.The same arguments used to invoke the method on the subclass are passedimplicitly to the parent. Arguments passed explicitly to SendSuperclass areignored and a warning message is generated at runtime.The SendSuperclass method returns current parameters without requiring abyref keyword. If invoking SendSuperclass causes the parent class to changethe value of an attribute, that change is returned automatically to the subclasswhen control returns to the subclass.130 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!