Strong Style Pairing

I’m a big fan and advocate for mob programming and have talked about it quite a bit. At the heart of mob programming is the idea of Strong-style pairing.

For an idea to go from your head into the computer it MUST go through someone else's hands

This is how I like to think about it:

strong style sketchnote

There's No 'I' in Agile

A great talk from Sam Laing about the “right” way to do testing in an agile team and the agile testing mindset.

My takeaways:

  • Testing is an activity like every other, not a stage to go through.
  • Ask “How do we test that?” on a regular basis.
  • Aim to do test tasks, like write a test plan, first - before any dev work.
  • Replace a test stage in your process with a “Show Me” stage so that even testing activities gets reviewed by someone else on the team.

Simulating Minecraft Creeper on Pi

One of the features missing from the pi version of Minecraft is the survival mode, where early on in the game you have to build a shelter to protect yourself from the things that go bump in the night.

Creepers are one kind of threat to your survival and in this code sample, I wanted to recreate something like a creeper to follow you around in the world. In survival minecraft a creeper will follow you if you come within range and will explode if it gets close enough to you. Nothing bad happens to you if the creeper catches up with you, obviously, but it’s still creepy enough that something out there is getting closer :)

I used obsidian blocks to build the creeper but could have used green wool or something to closer match the shade of the real creepers.

creeper


import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import random

# function to build the figure using the given material
def build_spooky_figure(world, x, y, z, material):
  # simple tower block for now
  for i in range(3):
    world.setBlock(x, y + i, z, material)

world = minecraft.Minecraft.create()

# intro...
world.postToChat("What ever you do ...")
time.sleep(5)
world.postToChat("Don't blink!")

playerTile = world.player.getTilePos()

# create the spooky block 20 blocks away
x = playerTile.x
z = playerTile.z + 20
y = world.getHeight(x, z)
build_spooky_figure(world, x, y, z, block.OBSIDIAN)

while True:

  time.sleep(random.randint(1, 5))
  build_spooky_figure(world, x, y, z, block.AIR)
  
  # track the player...
  playerTile = world.player.getTilePos()
  
  if (x - playerTile.x) > 0: x -= 1
  if (x - playerTile.x) < 0: x += 1
  if (z - playerTile.z) > 0: z -= 1
  if (z - playerTile.z) < 0: z += 1
  y = world.getHeight(x, z)
  
  # debug
  # world.postToChat(str(x) + " " + str(z))
  build_spooky_figure(world, x, y, z, block.OBSIDIAN)


creeper

Note that I started out positioning the creeper at a distance from the player and just using the player’s y coordinate, assuming that the terrain was flat at the place where the creeper spawned. Using the fixed y coordinate had the disadvantage that the creeper ignored things like hills (he burrowed straight through them) or valleys (he floated over them). Now I use the getHeight function which gets the height of the terrain at the current location so that the creeper behaves much more realistically, climbing over hills and going down into valleys.

Right at the start of the game I make reference to the weeping angels from Dr Who as a fun little easter egg for the participants on the programming course this code sample was written for, because creepers and weeping angels are similarly spooky in their respective fields.

PostScript

I did some more experimentation with the type of block used to build the creeper and found the closest to the original green and grey was the block.MOSS_STONE id.

creeper

Minecraft Pi for Millionaires

If you were a millionaire, living in a minecraft-kind-of-world, I’m sure you would want to have an enormously ostentatious fish tank for your block-shaped tropical fish to swim in.

fish tank


import mcpi.minecraft as minecraft
import mcpi.block as block

world = minecraft.Minecraft.create()

x, y, z = world.player.getTilePos()

x += 2
z += 2

# clear area
world.setBlocks(x, y, z, x + 20, y + 10, z + 20, block.AIR)

width = 8
height = 3
depth = 5
# glass block
world.setBlocks(x, y, z, x + depth, y + height, z + width, block.GLASS)

# fill it with water
x += 1
z += 1
y += 1

depth -= 2
width -= 2
height -= 1
world.setBlocks(x, y, z, x + depth, y + height, z + width, block.WATER)


Now that the fish are taken care of, the minecraft millionaire about town might like to own their own human fish tank, which we usually call a swimming pool. The code that worked for the fish tank can be sunk into the ground and work just as well as a lovely swimming pool.

swimming pool


import mcpi.minecraft as minecraft
import mcpi.block as block

world = minecraft.Minecraft.create()

x, y, z = world.player.getTilePos()

x += 2
z += 2

# clear area
world.setBlocks(x, y, z, x + 20, y + 10, z + 20, block.AIR)

width = 8
height = 3
depth = 5

# glass block in the ground
y -= height + 1
world.setBlocks(x, y, z, x + depth, y + height, z + width, block.GLASS)

# fill it with water
x += 1
z += 1
y += 1

depth -= 2
width -= 2
height -= 1
world.setBlocks(x, y, z, x + depth, y + height, z + width, block.WATER)



FizzBuzz in Elixir

Here’s the result of a recent junior dev coding dojo, tackling fizz buzz in a totally new language for us - elixir.


defmodule FIZZBUZZER do
  def fizzbuzz(value) when rem(value, 15) == 0 do
    "FizzBuzz"
  end
	
  def fizzbuzz(value) when rem(value, 3) == 0 do
    "Fizz"
  end

  def fizzbuzz(value) when rem(value, 5) == 0 do
    "Buzz"
  end
	
  def fizzbuzz(value) do
    value
  end
end
	

Everyone’s minds were blown with the inside-out-ness of the solution, providing several different implementations with the matching code “outside” of the body of the function.

fizz buzz

We ran the dojo using the wonderful cyber-dojo TDD tool (and forgot to change the name of the module away from the default Hitchhiker’s Guide to the Galaxy naming convention).

Slow Down

You periodic reminder to stop implementing code as fast as possible and slow down, maybe write a unit test or two :)

slow down

Seen on a factory wall at the Emma Bridgewater Stoke-on-Trent factory site.