class Recipe {
// Has ingredients & steps
}
// Do we set properties when initializing?
class Recipe {
constructor(ingredients, steps) {
…
}
}
// Do we allow setting properties after initializing?
class Recipe {
setIngredients(ingredients) { … }
setSteps(steps) { … }
}
// Do we allow both?
class Recipe {
constructor(ingredients, steps) { … }
setIngredients(ingredients) { … }
setSteps(steps) { … }
}
// Recipes are made by chefs
class Chef {
makeRecipe(recipe) {
…
}
}
// Does the chef turn on the oven?
class Chef {
makeRecipe(recipe) {
this.oven.turnOn();
recipe.make();
}
}
// Does the recipe turn on the oven only when needed?
class Chef {
makeRecipe(recipe) {
recipe.make(this.oven);
}
}
class Recipe {
make(oven) {
if (this.needsOvenPreheated) {
oven.turnOn();
}
…
}
}
// Which class do we add the purchase ingredients method to?
purchaseIngredients(ingredients) {
…
}
class Chef {
purchaseIngredients(ingredients) { … }
}
class Manager {
purchaseIngredients(ingredients) { … }
}
class Ingredients {
purchase() { … }
}
class Shop {
purchase(items) { … }
}