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 Classbeginif CurObject.TerminationDate = '' thenCurMethod.InfoPopup(messagetext ='Temporary employees must have a termination ' +date specified.', messagetype = MT_ERROR);errstat = -1;elseCurObject.TerminationReason = 'Contractperiod end';.errstat =CurMethod.SendSuperclass();endif;return errstat;endPermanentEmployee VersionBecause the TempEmployee subclass requires termination information for anew employee to be added to the database, it sets this information prior tocalling its superclass's version of the method.Unlike the TempEmployee class, which invokes the SendSuperclass methodonly after providing values for attributes critical only to that subclass,PermanentEmployee invokes the SendSuperclass method first and then doesadditional work.The PermanentEmployee subclass requires a successful insertion of newemployee information into the emp and jobs tables (performed by the parent'sversion of the method) before it adds a new row to the permemp table.Therefore, it forces successful completion of the first insertions beforeperforming its own insertion.The PermanentEmployee version of the Hire method handles the followingvalues for the defined attributes of the PermanentEmployee subclass:• NextReviewDate• VacationDays• InsurancePlan• BonusTempThe Hire method defined for this subclass inserts values from all of theseattributes into the permemp table. When this method is invoked on apermanent employee, rather than on its manager subclass, the value of thebonus_rate column of the permemp table defaults to null (only managers areentitled to a bonus).If the BonusTemp attribute had not been defined for the PermanentEmployeeclass, hiring a manager would require two separate database operations, aninsertion and an update (both into the permemp table). The insertion would bethe same one performed by the PermanentEmployee's Hire method, and theupdate would be required to store the manager's bonus rate.Working with Classes 133

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

Saved successfully!

Ooh no, something went wrong!