I have a class A that implements several functions class A is very stable.
Now I need a new feature, some of which match functionality which is implemented by A. I can not get my new class directly from Class A, because this will get a lot more redundancy my new class
So, should I be repeated in common code in both classes?
Or, should I make a new base class and move the normal class to the base class, and square A and get a new class from it? But this will change my existing class.
So, which would be a better perspective?
Until Class A, do not modify the refactor and a general base (or even Better, a normal class that can use both, but it is not necessary that they get).
You can always use personal heritage to gain access to the shared functionality without modifying the class as an external interface - this change will need to be rebuilt, but nothing else Exclude tasks, and forward them to the shared implementation class.
For one reason you do not want a refactor, but you can copy the code if it is possible that the functionality of the new classroom will change, but the same change will not be required in the old class. One of the reasons why the code is not duplicated is that one place or any change should be made only in one place. If the changes are going to occur, which will break the original class, then you probably want to copy the code instead. However in most cases, this happens when both classes do not look similar to what you think, and you may be fighting to try and summarize a general set of functionality.
Comments
Post a Comment