Skip to content

Instantly share code, notes, and snippets.

Created January 28, 2021 19:25
What would you like to do?
Article: Tell Don't Ask: Raised Bed
public class RaisedBed {
private final RaisedBedId id;
private final List<Plant> plants;
public RaisedBed(RaisedBedId id, List<Plant> plants) { = id;
this.plants = plants;
public WateringResult waterWith(WaterValve waterValve) {
for (Plant plant : plants) {
WateringResult result = plant.waterWith(waterValve);
if (!(result instanceof WateringResult.SuccessfullyWatered)) {
return result;
return WateringResult.success();
// truncated other methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment