Refactoring Day 6 : Push Down Field

Opposite of the Pull Up Field refactoring is push down field. Again, this is a pretty straight forward 
refactoring without much description needed 
 1: public abstract class Task 
 2: { 
 3: protected string _resolution; 
 4: } 
 5: 
 6: public class BugTask : Task 
 7: { 
 8: } 
 9: 
 10: public class FeatureTask : Task 
 11: { 
 12: } 
 
In this example, we have a string field that is only used by one derived class, and thus can be pushed down 
as no other classes are using it. It’s important to do this refactoring at the moment the base field is no 
longer used by other derived classes. The longer it sits the more prone it is for someone to simply not touch 
the field and leave it be. 
 1: public abstract class Task 
 2: { 
 3: } 
 4: 
 5: public class BugTask : Task 
 6: { 
 7: private string _resolution; 
 8: } 
 9: 
 10: public class FeatureTask : Task 
 11: { 
 12: } 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章