Notes on ‘Refactoring ‘ — 3.2 Replace Magic Number with Symbolic Constant
Before Refactoring validate1(){ if(size < 2){ addError(…); } } validate2(){ if(size < 2){ addError(…); } } After Refactoring static final int MIN_SIZE = 2; validate1(){ if(size < MIN_SIZE){ addError(…); } } validate2(){ if(size < MIN_SIZE){ addError(…); } }