It's Design
Posted by: K. Scott Allen,
on 26 Jan 2011 |
View original | Bookmarked: 0 time(s)
If I come across this code: if (widget.Price < 10.0m && widget.UnitsInStock > 100)
{
// ...
}
Then the first thing I'll suggest is refactoring to:
if (widget.IsEligibleForDiscount)
{
// ...
}
But It's Not Reusable!
"IsEligibleForDiscount will never be reused!", someone will shout. "Why do we go to the trouble if the logic is never reused?".
Ah, yes - but if we only use encapsulation as a means to generalize and achieve reuse, then we're not taking advantage...