We have a legacy system consists of class A, B and C. A is horrible and large. So is B. And C too!! (This is acknowledged within the company and we are trying to re-factoring them in the future).
The more scary thing is A and B extends C which they really shouldn't as they are not really the same thing. A developer (call him X) who did the coding admitted that he's done it this way so that A and B can use 'SOME' of the methods of C!
Now a client wants to update the legacy system and the change requires me to add the same change to A and B. What I can do is adding the change to C, so that A and B can see it. But if I do this I will be doing the same thing as X did.
What I have in mind is to write another class D, so A and B can have a D of their own and get the change. What do you think?
Thanks in advance!
Sarah
Makes sense. Josh Bloch also recommends in effective Java the use of composition over inheritance. While you're at it check if you cannot move a couple of the other shared routines over too. Many small steps cover a large distance.