|
Posted by Jerry Stuckle on 07/23/07 17:53
Sanders Kaufman wrote:
> Jerry Stuckle wrote:
>> Sanders Kaufman wrote:
>
>>> So - it's okay in the purist of OOP to have a child that presumes
>>> things about the parent, but not t'other way 'round?
>>>
>>
>> Not just a purist. Its the way things HAVE to be.
>
> That's what I meant.
> I was using "purist" in it's adjective form, not noun - as in, "the most
> pure".
>
Yes, I understand, but it's more than just being a purist.
The purpose of the derived class is to extend the base class. In order
to do that, it has to be able to make some assumptions about the base
class - like the fact the base class is initialized properly.
For instance, let's take the hierarchy:
Person
Employee
Manager
Person has name, birth date, etc. Employee has employee number, start
date, etc. And Manager has department managed.
Any time you're dealing with an employee, you should be able to assume
that the name, etc. are in there. For instance, let's say in the
constructor for Employee you need (for whatever reason) to know how old
that employee is. If he's under 18, (in the U.S.), certain restrictions
apply to what he can do. If you need to know that in the Employee
constructor, you need to be able to assume it's valid in Person.
Not a great example, I admit. But the easiest I can come up with right now.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|