Design Alternatives and Perspectives ◾ 253
Example 8.17: C# StudentEmployee: Student Parent
interface EmployeeI
{…}
public class StudentEmployee3: Student, EmployeeI
{
private Employee e;
// interface forces echo of Employee functionality
…
}
is third design, StudentEmployee3 is-a Student and contains an
Employee object, oers the additional benet of exibility relative to
the car dinality, association, and lifetime of the Employee subobject.
A StudentEmployee3 could have two jobs, zero jobs, or be in-between
jobs and still remain a student. e enduring type value of Student to a
StudentEmployee3 indicates why it is less desirable to subordinate Student
toEmployee.
A drawback to modeling inheritance with composition is loss of access ...