In message <[EMAIL PROTECTED]>, Mladen Milankovic
<[EMAIL PROTECTED]> writes
>On Thursday 20 March 2008 21:27:39 Pete wrote:
>>
>> I would usually use inheritance to make a new class, which I was going
>> to change, so as to keep the original class in place.  I don't see how
>> your suggestion would work in my case.
>>
>> I have a classA, and a classB, which both do similar things, but with
>> totally different code.  I now want to add FunctionC to both, but keep
>> it "in one place", to allow for code changes in the future.
>>
>> What would I be extending?
>
>
>Hi.
>
>It's not really extending as the keyword suggests, maybe it's better to say 
>inheretence. Probably will be more familiar in this maner, if you worked with 
>some real OOP languages.

I have, I was trying to keep it simple. (:->  I used to work with
Borland Delphi in the 90s.

>You create a class, let's say classC, which holds the FunctionC, and 
>everything else that is the same in classA and classB (any other function or 
>variable). Then the classA and classB can inherit the properties(variables) 
>and methods(functions) from classC

>In this situation both classA and classB will have the FunctionC which is 
>defined in one place which was the point of the whole thing.

I considered this before writing, but it would be "the tail wagging the
dog", and to me it doesn't make sense when going back to edit the code
in the future.  Both classA and classB are not really extensions of the
function, so it wouldn't make logical sense when you read the code.

Also, both classA and classB are already extended from other classes.

I think, simplest, is to leave it as it is!

-- 
Pete Clark

Reply via email to