Main menu:

Site search

Categories

July 2010
M T W T F S S
« Jan    
 1234
567891011
12131415161718
19202122232425
262728293031  

Tags

Blogroll

I don’t believe in signing up to stories for an iteration

If there is one thing that I hate about how a lot of Agile projects are run is the notion that you need to sign up to deliver certain stories/ a certain number of story points for an iteration. I find this to be detrimental on so many counts.

Firstly, if you don’t achieve the target then you feel bad, and feel really pressured the next iteration as now the project is running late. This tends to effect junior/inexperienced/graduate developers more than their experienced colleagues; they feel the pressure and so they work late to finish stories or (as I have once witnessed) coming in over a weekend to make up some ground. The real problem with applying this pressure arbitrarily is that most teams do not do root-cause analysis to find out why you didn’t achieve said target and work out what is slowing the team down/how they can go faster*. 

Secondly, if you do acheive the target, you generally do not increase the target for the next iteration which means that there is no chance for an s-shaped curve on the burn up graph (ie you don’t have the opportunity to go faster); and

Thirdly, when you achieve the target for the iteration, generally the next lot of stories are not ready, so you don’t have anything to work on and you tend to waste days. It also means that you are more likely to stall finishing the last stories (gas expands to fit the size of the room; developers expand the time it takes to complete a story to fit the time they have available)

Lean and KanBan offer an alternative to this approach: the backlog. Essentially, iterations are demarkations in time to allow you to reflect on your processes (yes, I know that in KanBan there are no iterations, and this reflection happens on an on going basis). To know what work needs to be developed for a day is all about prioritizing the top X stories (eg top 3 stories) in the backlog. That way, there are always X number of stories that have been analyzed and are ready to develop, the stories in development are the most valued stories (whether the value is to the business or to de-risk the project) and there is no bad pressure because you didn’t achieve what you set out to achieve. The only question that the team needs to be constantly asking and answering is:

“What can we do to make us go faster?”

 

* A retrospective as I detailed here may help in this case.

Notes from a brown bag session on Pair Programming

Pair programming may feel quite strange and frustrating to those new to it. (I guess it can feel strange and frustrating to those who have been doing for a while). I gave a brown bag session to a group who were just starting to embrace pairing to try and help them overcome some of their frustrations. Here are my notes from the session.

What are the concerns around pairing?

  • working with an argumentative pair – someone who wants to argue with you all the time, and disagrees with any approach you come up with
  • keyboard hogs – the other person wants to snatch the keyboard away from me all the time
  • unequal domain knowledge – one person knows everything, one person knows nothing so it is frustrating for the know-all to keep explaining everything all the time, and when they don’t the person who knows ‘nothing’ just tunes out.
  • differing styles
  • adds to the overhead – eg computer setup, time to bring someone up to speed on what is happening when you swap pairs frequently
  • I don’t have time to check my emails
  • there is no concept of ‘my computer’
  • you can’t get into ‘the zone’ when pairing, like you can when you are working by yourself because you always are interacting with another person
  • too much time rotating pairs
  • physical environment  - room to work
Why do we pair?
  • Shared responsibility
  • Knowledge transfer/sharing
  • collective code ownership
  • reduce key person dependancy (increase bus factor)
  • better quality
  • increased focus on the job at hand
How can we achieve it?
  • Teamwork 
    • working together to solve the problem. 
    • Both members remain engaged 100% of the teim. 
    • Ask when you are not engaged - ”You lost me, what are you doing now?”
  • Communication
    • Toss a few leading questions into the mix. Some of the phrases I usually say are:
    •  
      • “Should we do it in this way?”
      • “Do you know what we are doing?”
      • “Tell me what you are thinking?”
      • “Just let me try this and then we can discuss it.”
      • “What do you think?”
    • Think allowed – vocalise your thoughts, so you can bring your pair on the journey to the solution
  • Pass the keyboard around
  • Break the story into small tasks and write them down on post-it notes when you start a story. By breaking the story you are working on into small tasks, you can focus your attention on one thing at a time. Your mind does not need to wander thinking about all the other steps to solving the problems, as you know that you will eventually work on them. It also helps with rotating pairs through the story, as they can easily see what has been done on the story, what needs to be done and what they should focus on. 
  • KISS – Keep the solution and tests simple so there is less overhead when discussing complex solutions
  • On board new team members to bring them up to speed on the overall goal and design, so you do not need to repeat basic details when you work with them on a story.
Different Styles of Pairing
  • Ping pong – I write a failing test, You make it pass then write a failing test, I make it pass then write a failing test. Rinse and Repeat
  • Chessboard clock – this can either be achieved with an actual chessboard clock where every time you start touching the keyboard, you hit your part of the clock, when your partner touches the keyboard they hit their side of the clock, and you aim to keep the times on the clock equal. Or you timebox how long you will drive for, eg I drive for 10 mins, then you drive for 10 mins.
  • Inexperience partner drives – there is nothing like learning through your fingers, so let the inexperienced person drive. This style requires that the driver actually does a lot of work, and is not just a typist for the navigator. This works best if the inexperienced person can explain what they want to do, eg “I want to call some sort of repository for this value then I can go on.” so the experienced person can show where the file is.
  • 2 keyboard and 2 mouse(s)
  • Doesn’t matter who ‘drives’ – when you have two people experienced in pairing as both people do the design verbally, and the person at the keyboard just conveys the conversation to code (often the fastest typist)

Pair programming is just like flying a plane

I have been reading Malcom Gladwell’s Outliers, and in it he discusses the events which lead to plane crashes. Gladwell explores the plane crashes of Korean Airlines to demonstrate that cultural legacy is important to understand success factors. One interesting point he explores is the communication required in the cockpit between the captain and the co-pilot.

Interestingly the flight deck of large commercial planes, like the Boeing 747 is intended to be flown by 2 people and it works best when you have one person checking the other, or both willing to participate. “It’s .. clear that when you have two people operating the plane cooperatively, you will have a safer operation than if you have a single pilot flying he plane and another person who is simply there to take over if the pilot is incapacitated”. Apparently, and surprisingly, most crashes (of the Korean Airlines) occurred when the captain was piloting the plane (someone who has many hours of experience), as opposed to the co-pilot (who typically does not have as much experience). This is because if the senior captain sees something wrong that the co-pilot is doing, then he will issue a command to the co-pilot to correct the situation. However, if the co-pilot sees something wrong he will not issue a command to his superior officer as a command, and will either hint at or suggest a correction. It is clear that clear communication is the essential ingredient to correcting otherwise fatal sequence of events*.

Unfortunately for the crew and passengers aboard the fatal Korean Airline planes, Korea has a culture of high respect for authority expressed in both their customs and their language. So, the cultural forces behind the Korean co-pilots makes it nearly impossible for them to speak up and correct the captain, even when they know that the captain is in the wrong (read the book – the black box recordings are amazing). What turned Korean Airlines around? They realised that the problem was not to do with the experience of their pilots or the maintenance of the planes, but that it was this cultural force which was at fault. They hired some help, enforced English (which does not have an inbuilt respect for authority) as the only language which could be used in the company, and as a result helped the co-pilots have the confidence to speak up when there was a problem.

Now, don’t get me wrong – I find airline investigation to be truly fascinating (have you ever read about the lead up to the flight on the Challenger? It wasn’t just the O-rings fault). But the most interesting take-home for me was how the cockpit experience parallels pair programming.

Pair programming is intended for 2 people, and works best when you have one person checking the other, or both willing to participate. It is clear that when you have two people working cooperatively you will have a safer (ie higher quality) software than if you have a single developer developing the work and another person who is simply there to take over. Pair programming works well when you have the less experienced developer at the keyboard flying the development, and the more experienced developer course correcting when the co-pilot makes a mistake. And just like the cultural forces that caused so many disasters for Korean Airline, the cultural forces of the development community leads to many pair programming sessions, crash-and-burning.

There are many people out there who only experience the forces that lead up to pair-programming disaster stories. It can be very dismissive of us to say that these people just don’t get it (and never will), or that they haven’t tried hard enough, but Gladwell has lead me to start believing that there is a cultural bias towards single programming. Take universities for example – you can be expelled for working collaboratively; individual results count, team work in assignments is often discouraged.

Korean Airlines managed to change their practices despite of their culture; I am confident that anyone who is willing to can change their practices to have a successful pair programming flight. The first step as always, is to acknowledge the problem.

 

* Typically, plane crashes occur as a result of seven trivial malfunctions, which, individually is no problem but the combination of all those errors leads to disaster. Typically crashes occur when the weather is poor, when the plane is running late and when the pilot has been awake for more than 12 hours. 44% of the time two pilots have never flown together before. (page 184 Outliers Gladwell, M)

Improvements to the usual stand up meetings

Stand-up meetings are a healthy part of the daily routine. They are a useful forum to keep everyone up to date with the happenings of the team, escalate any blockers that may have arisen and set direction and focus for the days activities.

However, in practice they can easily degrade to daily habits, where each person talks, no one listens and nothing is accomplished. Observable signs that this is happening in your team:

  • there is low energy – people walk away nonchalantly
  • the developers say “I worked on xyz story. Today I will work on xyz story. No Blockers” (Yes I know – I can see the story board and we were all there when you picked it up)
  • their pairs say “yeah, what he said”
  • the QAs say “I tested stuff yesterday, I will test stuff today”
  • after the meeting, a conversation ensues along the lines of “Oh, the builld’s not running. Hey everyone, I have just spent 20 mins looking at it and there’s something really wrong with the box as it doesn’t even respond to pings.” “Yes, I know. I have brought down the network for the moment to install the latest patch. I said so in the standup this morning.” 

 

Needless to say, the standup is no longer a useful forum. The major problem with this style is that people tune out because no one is saying anything of value. They are usually repeating common knowledge (by stating on what they were working on, when the whole team can see that by the story wall).

At my current project, we faced a similar problem*. So, I changed the rules of our stand up.

The new format

  1. No one is to say anything in the format What I Did Yesterday; What I Will Do Today; Any Blockers. This format is scrapped, binned. 
  2. Instead, I only want you to tell the team what you think is valuable to them; what did you do or find yesterday that is of value sharing with the team; what do you know, that we need to know.
  3. The only person allowed to be speak will be the person holding the speaking token.
  4. If something has just been said that you feel you should to add to, answer or have question, all you need to do is signal for the token (hand gestures along the lines of “Pick me Pick me” will be rewarded). 
  5. If someone requests the token, the token-holder finishes the sentence and passes the token along to the requester.
  6. Every member has a red card. If a discussion starts, and you are not interested in it, you raise your card. Two cards (dependent on the size of the team) and the conversation is immediately (mid-sentence) stopped and is taken offline.
  7. When you have finished sharing, you throw the speaking token to someone who is not to your immediate left or right. 
  8. If you don’t feel you have anything of value to add, you can pass the token onto another person.
  9. The standup does not remove the need for us to talk to each other throughout the day.

The Result

Our meetings are quite high energy, high paced and highly informative. Everyone adds value and we all walk away from the meeting energised and ready for action. Our meetings allow for useful discussions to start, but also allows for a mechanism to control them if they are getting out of hand. If suddenly you find the same repeat offender does not have anything of value to add, that is feedback; perhaps the person is a little shy, perhaps they have been slacking off – either way, if they don’t feel like they can say anything of value now, what were they saying in the old method. Blockers are still talked about, as they usually have value. Also, having a cute throwable soft toy helps.

 

* Actually, before we faced this problem, we had the problem where no one would start talking. The introduction of a speaking token  solved that problem.

It is a truth (not so) universally acknowledged…

that an agile team in possession of good practices, must be in want of a better way of doing things.

A New Take on the Hot Air Balloon Retrospective

I am not a huge fan of the iteration-based retrospectives that people usually run. These are the retrospectives in the format where you write about

  • What We Did Well
  • What We Did Less Well and
  • What’s Puzzling Us

I find with these retrospectives, the same issues seem to crop up, with actions that don’t get resolved and nothing really improves for the next iteration.

I think the main reason we should do iteration-based retrospectives is to focus on what will make us go faster next iteration, and what are our current impedances. The best retrospective ‘game’ I have seen to support this is the hot air balloon/speed boat** analogy. This means that issues should not get raised which do not directly impact how fast we could potentially go. I have tried this exercise before, and have found that it was too broad a scope, and so not many new ideas came out***.

Yesterday, I tried a variant on the hot air balloon exercise, with really good results.

The New Format

  1. Place the stories of the iteration (stories that were completed, in QA, in development and ones not started) on a wall in a pseudo timeline
  2. Group any ‘bug’ cards around the stories to which they belonged (these ‘bugs’ were issues that the QAs found which meant that a story could not be QA signed off and therefore needed more dev effort).
  3. Describe the story on the wall (similar to the timeline game), to get everyone back into the mindset of when they were working on the stories. It is also useful to state the estimate for the story and the actual time it took to deliver.
  4. Give the group time to write stickies for each story, with the focus on why they thought the story took longer to complete or was faster than expected. The idea is to explain the hot air balloon metaphor, and get them to focus their thoughts for each particular story. Essentially, I said to them “What was the magic sauce that made this story really quick and easy to do; and what was the crud that got in the way?”
  5. Walk through each sticky note, identify themes, discuss and record any action items.

The Result

The issues that we discussed highlighted problems that were not caught doing the usual style. The actions from the issues discussed directly corresponded with ways to improve the velocity of the team.

By turning the focus onto each story lifted the pressure of having to think generally out of the box, and focussed the teams effort to think about what was really the problem. This highlighted not only external problems, eg too many meetings, but also lead to an examination of the code base, eg It took me too long to add that line to the screen so I think that area of code needs a clean up.

All in all, this is an exercise that I will repeat.

** The narrative I give with the hot air balloon goes something along these lines. “The hot air balloon is like our velocity, it has the potential to go really high (fast) but the problem is two-fold. We have sandbags (impedances) which are currently actively slowing us down and we don’t have enough fire (which is trying to lift us up). So lets think about what in our project are our sandbags and what is our fire. What is slowing us down, and what could we do to go faster”. The speed boat has anchors in the water as impedances and an engine as fire.

***  Actually, I played this after weeks of the usual retrospectives defined above and most of the what we did well stickies were placed in the fire area, and the what we did less well were placed in the sand bags.

Surf’s Up meets Software Development

I have just finished watching the special features of Surf’s Up on the DVD and I was struck with a thought that software development is somewhat similar to making a movie, and if you allow me to draw the parallels, you can see that Surf’s Up was created in a very Agile way.

Surf's Up DVD - created in an Agile way

Surf’s Up was created differently to most animated films [1]. Traditionally, most movies are writen by a script writer, then handed to the actors who need to confine themselves within the lines of the script. In Surf’s Up however, the directors put a lot of focus on getting real genuine conversations from the actors. To aid this they did a few things.

First, the dialogue was recorded with all actors together in the booth; most animated films record the voices independently. Co-locating the actors meant that the reactions and interactions were genuine, not just something which had to be faked.

Also, the directors put alot of focus on letting the actors ad-lib their lines. While there was an overarching story they were telling, the specific details of the dialogue was left to the actors imagination. 

Now, I hope you can see where I am going.

Recording the dialog with all the actors together is much like co-locating your delivery team. This has various benefits:

  • the team quickly build up a rapport and their chemistry can be seen (or heard) on screen;
  • any changes to the script or subplots can be developed in-situ, and do not require dragging actors who have already recorded their parts back to the studio to fix the dialog for the new requirements (ie any changes to the requirements can easily be dealt with as the team is all together, working toward the goal simultaneously);
  • it could be cheaper/faster to record (develop) with everyone in the one place as you do not need to keep repeating the setup for each new actor who comes to record their part (actually, I am just guessing on this one, but you can see where I’m going).

Letting the actors ad-lib their lines is analogous to getting developers to design their own code (hopefully through TDD/BDD/DDD). The architecture of the software is like the story they are telling, and the implementation details is like the dialogue in the script. By allowing the actors to improvise, the directors have allowed the actors to develop each character in a unique way, bringing their own personality to the foray. This meant that the actors were also responsible for steering the ship: an example is the cute, funny character of Arnold was apparently developed by Zooey Deschanel (who plays Lani) during one of the ad-lib sessions.  

Surf’s Up is a pretty cool movie, one which you can easily forget that you are actually watching animation. No doubt its success has something to do with the manner in which it was made.

How does Architecture fit with TDD

The question a lot of people (especially software architects) ask when adopting TDD is how does Architecture fit in the whole Test Driven Design paradigm.

Traditionally, any new functionality is vetted by a software architect who completely designs it (on paper) and sometimes adds the foundation to the code base. The developers in the team then take the designs and implement them, sometimes in a cookie-cutter fashion. The developers often don’t understand the design (at least why it is in the form that the architect has specified) and when they start to query it get negative reaction from the architect.

The question is, if we now say our tests will drive out design, where does the architecture go? Won’t this just lead to a micro-optimisation, without anyone looking at the system as a whole. Chaos!

In my mind, the role the architect plays in this brave new world is to provide the team with a 50000-ft view of the system. The architecture declares that MVC will be used, how the infrastructure is strung together, but it does not specify which classes will be created, what services will be used and what design patterns will be used. These are really implementation details, and are the elements which are driven by your tests.

Other XP and agile principles will also help with ensuring your newly TDD code base does not turn into chaos. If you adopt a domain driven design approach, then your business layer and logic will be driven out by the business and you will know from that which classes need to be created, what should be a service and what are your repositories. If you adopt pair programming, then the ‘architects’ experience can be shared with other team members and the knowledge of what constitutes good design increases, lessening the role of the architect. 

So, how does Architecture fit into TDD? Quite nicely, I think.

A conversation with a TDDer

This is part of a conversation I had this week with my pair (in the conversation, I am A and he is B) as we were working on a new story. He, like many others, has been trying to do TDD but it wasn’t until we had this conversation that he began to understand what I was talking about in my last post – that Test First does not drive out good design, but Test Driven Development can.

A: What are we trying to test

B: The instrument controller

A: Ok, what is it meant to do

B: Well, we are going to send it an instrument and its going to go to the Songs table in the database and query it for songs which use that instrument and then its going to render them on the page

A: Hmm – that sounds like how. What is it meant to do?

B: Umm – find the songs that use the instrument and display it on the page.

A: That sounds pretty good. Except is it responsible for displaying it on the page or is that the responsibility of the view object?

B: Yeah – the view object actually renders it.

A: Ok – perhaps we can say that the instrument controller is responsible for finding the songs that use the instrument and returning it in a form that the view object can use.

B: Sounds good.

A: Ok, so what’s our first test

B: Well, we give it an instrument and it should find all the songs and return them.

A: That seems to be a lot for our first test. Perhaps we should split that into two tests and have one which returns a list of songs and one that asserts the songs are correct.

B: Cool, sounds good

A: Ok, so the first test name could be ShouldReturnListOfSongs and the second test could be ShouldReturnSongsWhichUseTheGivenInstrument. So, we want to assert that we get a list of songs. It is often useful to work bottom-up: work from the assertion up to the setup.

public void ShouldReturnListOfSongs()
{
	// Given

	// When

	// Then
	Assert.IsTrue(returnedList is List<Song>);
}
public void ShouldReturnSongsWhichUseTheGivenInstrument()
{
	Assert.Fail()
}

B: But where does returnedList come from

public void ShouldReturnListOfSongs()
{
	// Given

	// When
	InstrumentController controller = new InstrumentController();
	List<Song> returnedList = controller.FindSongs();

	// Then
	Assert.IsNotNull(returnedList);
}
public void ShouldReturnSongsWhichUseTheGivenInstrument()
{
	Assert.Fail()
}

A: Ok – your turn. Lets do the simplest thing to make that pass

public class InstrumentController
{
	public List<Song> FindSongs()
	{
		return new List<Song>();
	}
}

B: Cool. Ok, now I want to test that it finds the right songs from the database

A: Testing that we get the correct songs is good, but its not the responsibility of the controller to know that it is getting the songs from a database. What happens if you want to change your storage mechanism? Now you have to change everywhere that you just pulled information straight from it. Anyway, thats a how again. Lets get back to what it should do: return the songs which use the instrument.

public void ShouldReturnListOfSongs() { ... }
public void ShouldReturnSongsWhichUseTheGivenInstrument()
{
	// Given
	Song hereComeTheDrums = new SongBuilder().Build();

	// When
	InstrumentController controller = new InstrumentController();
	List<Song> returnedList = controller.FindSongs("drums");

	// Then
	List<Song> expectedSongs = Lists.Build(hereComesTheDrums);
	Assert.AreEqual(expectedSongs, returnedList);
}

A: Notice I have used a builder – this is so that our setup is not long, we know we have a valid Song object and if at anytime we need to change the way a song was constructed, we would only need to change the builder – not every test which created a Song. Now, we know that the controller needs to ask another object to do the finding, as it is not the controllers responsibility. An objet that usually encapsulates that work is called a Repository. As far as the controller is concerned, the Repository holds a bag full of Songs and it can ask it for songs that use instruments. It is the responsibility of the repository to actually find the songs. So, lets give the controller the repository when it is created.

public void ShouldReturnListOfSongs() { ... }
public void ShouldReturnSongsWhichUseTheGivenInstrument()
{
	// Given
	Song hereComeTheDrums = new SongBuilder().Build();
	ISongRepository songLibrary = new CannedSongRepository(hereComeTheDrums);

	// When
	InstrumentController controller = new InstrumentController(songLibrary);
	List<Song> returnedList = controller.FindSongs("drums");

	// Then
	List<Song> expectedSongs = Lists.Build(hereComeTheDrums);
	Assert.AreEqual(expectedSongs, returnedList);
}

A: Again, note that the controller takes in an interface and in the test we are using a Canned repository. A canned object is useful in testing as we can guarantee what it returns. Some people use mocking frameworks to stub the method call; the difference between a canned repository and a mock is that we can reuse the canned object without any effort in other tests, but we would need to recreate the mock every time. That leaves us with a failing test.

public class InstrumentController
{
	ISongRepository songLibrary;

	public InstrumentController(ISongRepository songs)
	{
		songLibrary = songs;
	}
	public List<Song> FindSongs(string instrument)
	{
		return songLibrary.Find(instrument);
	}
}

A: Right, now the only problem with the code is that I don’t really understand what the method Find does. I can’t look at it and instinctively know what it will do. It is not an intention revealing method name. Perhaps we can call it FindSongsWhichUse so that the code now reads

public class InstrumentController
{
	ISongRepository songLibrary;

	public InstrumentController(ISongRepository songs)
	{
		songLibrary = songs;
	}
	public List<Song> FindSongs(string instrument)
	{
		return songLibrary.FindSongsWhichUse(instrument);
	}
}

A: Now we have a choice – we can continue testing the controller or we can start testing the repository. If we test the repository, we can continue with a thin vertical slice, we can see the results on the page and get immediate feedback (this is my preferred method)

And so the development (and conversation) continued until we ended up with a nice design which was fully tested and only delivering what the business wanted.

What is a good test?

I have been helping my current client introduce TDD, and in doing so explaining principles such as single-responsibility, encapsulation and intention revealing names. As I said in my previous post Test first does not magically improve the code base, but you need to concentrate on writing good tests to help you drive out good design. This is my list of what I think characterises a good test (although I don’t think its definitive – I am sure I have missed some things out).

 

  • Test the what, not the how. Concentrate on the behaviour of your object, not how it will achieve that behaviour.
  • Have minimal, simple setup. This will help drive out classes which have low dependancies, low coupling and single responsibility. Use builders to help you minimise the number of lines in your setup.
  • Write your test bottom up – start with your assertion, then fill in the blanks
  • Test one behaviour at a time (often referred to one assertion per test). If you hear the magic keyword And when describing the behaviour, you have two tests.
  • It is useful to structure your test in the Given When Then format. This allows you to see the what is just there to form as setup and how much setup you need to do (in the Given), see the intention of the test (in the Then) and understand which method you should alter to make the test work (in the When).
  • Naming is important. Give your test a good name – it will help with your documentation and it will also help you concentrate on what you are testing, not how it will be implemented. Also, names of your test variables should reveal the different examples of the values that could be used. Instead of declaring User user = new User(“mary jane”) try User maryJane = new User(“mary jane”) and see how that changes your understanding of the class.

In my next post I will share a conversation I had this week with my client, which shows how I introduce these characteristics to my test.