Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 1.5

COLUMN

Is an Employee a Person?

Subclassing an employee class

Issue: 1.5 (April/May 2003)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a software developer in Lexington, Kentucky.
Article Description: No description available.
Article Length (in bytes): 5,012
Starting Page Number: 36
Article Number: 1518
Related Link(s): None

Excerpt of article text...

You're writing a small business accounting application, so of course you'll want to add an employee class. And, since the majority of businesses only employ people, class Employee should inherit from class Person. But what happens when this person leaves the employ of the company using your software, and returns as a consultant?

I've encountered this very problem in some well-known Macintosh accounting applications. What happens is that your user will be forced to re-enter the person's information to reincarnate him as a consultant.

One alternative to subclassing would be to define Employee and Vendor interfaces, and have Person implement both interfaces. But this doesn't feel right; the result is to turn the Person class into a union of the Employee and Vendor. If we consider this solution from the database end, it's clear that there will be a lot of wasted space as fields go unused for the majority of people who are not vendors.

...End of Excerpt. Please purchase the magazine to read the full article.