Skip to content

Instantly share code, notes, and snippets.

@yreynhout
Created October 13, 2012 14:07
Show Gist options
  • Save yreynhout/3884730 to your computer and use it in GitHub Desktop.
Save yreynhout/3884730 to your computer and use it in GitHub Desktop.
Simple stab at deferred decision making
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