Skip to content

Instantly share code, notes, and snippets.

@pawelpluta
Last active October 8, 2020 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelpluta/2c3ff31f5874a5448be900e3eb5685dc to your computer and use it in GitHub Desktop.
Save pawelpluta/2c3ff31f5874a5448be900e3eb5685dc to your computer and use it in GitHub Desktop.
Article: The OOP has been explained wrongly to you
class WashingController {
private final WashingService washingService;
WashingController(WashingService washingService) {
this.washingService = washingService;
}
void wash(Fabric fabricType) {
Collection<LaundryElement> laundry = getAllLaundry();
WashingMachine washingMachine = new WashingMachine();
if (fabricType == Fabric.WOOL) {
washingService.washWool(washingMachine, laundry);
} else if (fabricType == COTTON) {
washingService.washCotton(washingMachine, laundry);
} else if (fabricType == SILK) {
washingService.washSilk(washingMachine, laundry);
}
}
private Collection<LaundryElement> getAllLaundry() {
Collection<LaundryElement> allLaundry = new ArrayList<>();
// fill the allLaundry collection with available laundry by any way,
// e.g. obtaining it from repositories, providers, services
return allLaundry;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment