Created
October 13, 2012 14:07
-
-
Save yreynhout/3884730 to your computer and use it in GitHub Desktop.
Simple stab at deferred decision making
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RenovationPolicy { | |
public RenovationRequest FileRequestFor(Building building) { | |
if(building.WasBetween(10.YearsAgo(), 25.YearsAgo()).WhenConstructed()) { | |
//... | |
} | |
} | |
} | |
public class Building { | |
internal BuildingAgeConstraint WasBetween(Date lower, Date upper) { | |
//Forwarding of private state to be able to defer decision making | |
return new BuildingAgeConstraint(_constructionDate, lower, upper); | |
} | |
} | |
public class BuildingAgeConstraint { | |
public BuildingAgeConstraint(Date constructionDate, Date lower, Date upper) { | |
_constructionDate = constructionDate; | |
_lower = lower; | |
_upper = upper; | |
} | |
public bool WhenConstructed() { | |
return _constructionDate >= lower && _constructionDate <= upper; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment