Skip to content

Instantly share code, notes, and snippets.

@caseykulm
Last active September 7, 2017 14:21
Show Gist options
  • Save caseykulm/fa926f97983dbdb5d41b00ce2207f38e to your computer and use it in GitHub Desktop.
Save caseykulm/fa926f97983dbdb5d41b00ce2207f38e to your computer and use it in GitHub Desktop.
Inject Functions: 2
interface TreatFactory {
fun getTreats(): Treats
}
class Petco: TreatFactory {
fun getTreats(): Treats {
// Details of how to get to Petco,
// what aisle the treats are on,
// what treats they carry that doggo
// likes, etc.
}
}
data class DoggoStash(
val leash: Leash,
val waterBowl: WaterBowl,
val bed: Bed,
val treatFactory: TreatFactory)
fun proceedOnRoadTrip(doggoStash: DoggoStash) {
getDoggoLeashedUp(doggoStash.leash)
packupWaterBowl(doggoStash.waterBowl)
setupBedInBackSeat(doggoStash.bed)
startDriving()
stopForTreats(doggoStash.treatFactory)
}
val leash = DoggoLeash()
val waterBowl = WaterBowl()
val bed = Bed()
val treatFactory = Petco()
val doggoStash = DoggoStash(leash, waterBowl, bed, treatFactory)
proceedOnRoadTrip(doggoStash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment