Refactoring Day 4 : Push Down Method
Yesterday we looked at the pull up refactoring to move a method to a base class so mutiple derived classes can use a method. Today we look at the opposite. Here is the code before the refactoring:
1: public abstract class Animal
2: {
3: public void Bark()
4: {
5: // code to bark
6: }
7: }
8:
9: public class Dog : Animal
10: {
11: }
12:
13: public class Cat : Animal
14: {
15: }
</p>
1: public abstract class Animal
2: {
3: }
4:
5: public class Dog : Animal
6: {
7: public void Bark()
8: {
9: // code to bark
10: }
11: }
12:
13: public class Cat : Animal
14: {
15: }
</p>
This is part of the 31 Days of Refactoring series. For a full list of Refactorings please see the original introductory post.