10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

InheritanceClass RelationshipsYou can create user classes to structure your organization's data into objects.These objects, with all of their characteristics and behaviors built in directly,can serve as the basis for your applications.Before creating classes to represent your data, you must understand the twobasic kinds of relationships between classes. Only after you have clearlyidentified a class and its relationships to other classes can you best defineattributes and methods at the most general level. These kinds of relationshipsare:• Inheritance Hierarchy (or Generalization/Specialization)• Aggregation (or Containing)Inheritance Hierarchy (Generalization/Specialization)The inheritance hierarchy inter-class relationship assumes that each classdefines its own attributes and methods and inherits those defined for itssuperclass.In developing an application for managing a company, you might define asuperclass called Employee with two subclasses, PermanentEmployee andTempEmployee. Because every employee must be either permanent ortemporary, Employee is an abstract (general) class that defines attributescommon to all employees, such as LastName, FirstName, EmpNum, andHireDate. PermanentEmployee and TempEmployee are specialized classes thatrepresent actual employees.The PermanentEmployee and TempEmployee subclasses inherit the attributesof Employee. In addition to the Employee attributes, PermanentEmployeedefines attributes specific to its class, such as InsurancePlan andNextReviewDate.Because managers are a specific kind of permanent employee, you mightdefine a Manager user class that is a subclass of PermanentEmployee. Inaddition to the attributes inherited from both of its superclasses, this class alsohas a BonusRate attribute.Methods common to all staff are also defined at the top level. The Employeeclass, for example, defines the Hire and Terminate methods. Methods specificto a subclass are defined at the subclass level. For example, the Manager classmight define a CalculateBonus method.122 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!