It was mid-morning, and rather in need of a cup of tea I decided to let my colleagues know that I would be AFK by hurriedly typing the following into the team chat window:
Alec: mug = new Tea();
This was meant to be a joke, and yes I paused over the syntax for a moment before hitting Send but I thought nobody would bother if it weren’t quite semantically orthogonal.
Big mistake. I returned to find:
Richard: I think you’re getting your types confused there, surely a mug has a different type from tea? Perhaps something like:
mug.push(new Tea());
Or even:
mug.pop(); mug.push(new Tea());
depending on whether or not you finished the last one.
Gareth: Agreed. We’re assigning a container type to the contained. There’d be tea everywhere. #illgetmecoat
Simon:
Vessel mug = VesselCollection.getVessel(Mug.class);
mug.push(Tea(
BeverageAbstractFactory.get(
Resource.get("tea.properties").getBeverage(
Tea.class,
VesselCollection.getSizeForVesselType(Mug.class)))));
– Of course, that’s assuming you don’t complicate the issue with dependency injection
Max: Maybe: mug.contents = new Tea();
Max: “dependency injection”? What like milk?
Simon: I started writing a Spring Beans XML file for this, but then remembered I have an actual job 🙂
Lloyd: Event based:
mug.on("empty", function() {
tea = function() {
water = { temperature: '100'};
teabag = setTimeout(function() { return teabag; }, 30000);
extras = {};
if (hasMilk) extras.milk = true;
if (hasSugar) extras.sugar = sugarCount;
return { water, teabag, extras };
}
this.fill(tea); });
Lloyd: ….and on that note: mug.emit('empty');
Ash:
kettle.add(tap.getWater(0.5, Unit.KETTLEFULL));
kettle.startBoiling();
mug.empty();
mug.addItem(instantCoffee.getCoffee(1, Unit.TEASPOON));
kettle.addBoiledListener(new KettleBoiledListener() {
public void boiled() {
mug.addItem(kettle.getWater(1, Unit.MUGFULL));
mug.addItem(fridge.get(Milk.class).getMilk(30, Unit.ML));
}});
Alec: (back) …and now I’m just waiting for Kevin to step in with a Gantt chart.
Kevin: All my gantt charts have been washed away
Richard: @Inject Mug ofTea;
From Lloyd I subsequently received a debugged and working node.js wrapper for the above fragment.
So: attention to detail is above par. I’m only surprised I wasn’t asked to put a TDD framework around it.
Written by: Alec Muffett