Skip to content

Instantly share code, notes, and snippets.

Last active January 28, 2021 18:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Article: Tell don't ask - watering after refactoring
public class Watering {
private final RaisedBedRepository raisedBedRepository;
private final WaterValveRepository waterValveRepository;
public Watering(RaisedBedRepository raisedBedRepository, WaterValveRepository waterValveRepository) {
this.raisedBedRepository = raisedBedRepository;
this.waterValveRepository = waterValveRepository;
public WateringResult perform(WateringCommand command) {
// cut out: getting raised bed with plants and wattering bed
return waterBed(raisedBed.get(), waterValve.get());
private WateringResult waterBed(RaisedBed raisedBed, WaterValve waterValve) {
WateringResult successfullyWatered = raisedBed.waterWith(waterValve);;;
return successfullyWatered;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment