jump to navigation

Greedy software development (with backtracking) July 4, 2005

Posted by andy in : coding , trackback

After working in an eXtreme Programming house for 1 week I am now fully qualified to discuss it.

My conclusion? It’s good.

My slightly nerdier conclusion? It’s a greedy algorithm (with backtracking) for software development.

When people talk about XP they tend to say a lot of things about it. They either say it’s the greatest thing to ever hit software development ever, or they say that it is… well… ramshackle. I don’t think it’s either of those things.

It’s just a way of developing software that picks the easiest solution at any time and sees how it goes. That’s a greedy algorithm. Quite often greedy algorithms are good at approximating an ideal solution, but they rarely actually attain it. And there’s normally better ways to get there. This is why backtracking is often employed to improve greedy algorithms. Backtrackers go through a greedy solution and improve them, tidying them up. That is what refactoring is to XP. A code-base created from thousands of good short-term decisions would be an absolutely hideous mess. Backtracking and fixing it up is key to producing quality.

XP doesn’t produce optimal solutions, but it approximates them using a few key principles that it appplies to its greedy approach.

Traditional software development talks a lot about upfront design, documentation, test suites and so on. These are generally things that developers don’t know much about. Even if they do, they generally don’t know anywhere near as much about them as they do about coding.

But devs are good at cutting code and, when suitably motivated, they are good at testing it. This is where the enforced test-code-think-refactor-test-code-think-refactor cycle comes in. Devs are also people, and thus they have a tendency to want to avoid doing anything that is outside of accepted social norms. While some people would say that geeks tend to live WELL outside social norms (and who am I to disagree) they still try to stay within the bounds of their own social constructs. This is where pair programming comes in.

I don’t think it would be too much of a stretch to say that without enforced pair programming XP would be absolutely worthless. When XP practicioners have said this to me in the past I have thought it was bullshit, but it is such a fundamental aspect of the success of XP that I am now forced to agree.

Pair programming does the following

  1. Catches simple bugs using 2 pairs of eyes
  2. Catches design problems using 2 pairs of eyes
  3. Creates an active discourse on the problem, which leads to better solutions
  4. Keeps developers on track

While points 1-3 have been those really emphasised in my previous discussions on pairing, point 4 is the killer. Unit tests catch point 1. Peer reviews catch 2. Group design discussions catch 3. They may not do it IMMEDIATELY, but they DO catch it. But you can’t get point 4 without pairing.

I’ll freely admit that I am LAZY. I like to dick around, talk to people, chat about my day, read emails, browse my usual sites and all that. I’d say that out of a full 8 hour work day, if I was being honest, I’d normally work maybe 4-5 hours. Maybe.

Pairing I work ALL day. The entire day. And I really don’t mind.

Being in a pair does two things. It forces me to talk to someone else about the problem, which makes better solutions, but it also forces a social pressure on me: The pressure to not waste my partner’s time. If I start reading my email or looking at Slashdot, that leaves my partner sitting there doing nothing. How rude would that be? Rude enough to make me not want to do it. So I work hard because not working harder would just be plain rude.

That happened to me today at work and it made me really really fucking angry.

So yes, suffice it to say that I appreciate having a full test suite with 80+% coverage (there’s nothing like commiting code and knowing that it doesn’t break anything), and I like writing my unit tests first, and I like the opportunity to tear code apart and rework it if it seems dumb. But I really really like pair programming and I don’t know why, because i don’t get to read Dinosaur comics so much.

Comments»

1. RodeoClown - July 5, 2005

I declare: Thigh fives all around!

I know EXACTLY what you mean re: pair programming.
I do loads more work when someone is staring over my shoulder. It gives a bit more motivation to start working I think. In fact I think you know EXACTLY what I mean, having sat next to me for a while.

Only time it doesn’t work is when both people want to read dinosaur comics. I cannot stress this enough.

2. RodeoClown - July 5, 2005

OK, one more thing (sorry).

You need to fix your RSS link on the sidebar.
It should be: http://andy.5263.org?feed=rss2

It isn’t currently, and I only got it, because it uses the same as my feed…
http://home.exetel.com.au/rodeoclown/?feed=rss2

3. andy - July 5, 2005

Okay… I’ll take a look tonight.

Damn straight about dinosaur comics though. They are evilly addictive.

If I saw one of them in the street, I’d lick my lips and say “Hello…”

4. vending machine - January 22, 2008

vending machine

http://uswebstore.freepimphost.com/vending-machine vending machine

5. marc jacobs handbag - January 25, 2008

marc jacobs handbag

http://www.geocities.jp/topbagseason/marc-jacobs-handbag marc jacobs handbag

6. proscar - February 1, 2008

proscar

http://m.domaindlx.com/goodsites/proscar proscar

7. bathroom showers - February 2, 2008

bathroom showers

http://good4u.host93.com/bathroom-showers bathroom showers

8. adt security - February 2, 2008

adt security

http://usatop.freehostpage.com/adt-security adt security

9. pottery barn - February 3, 2008

pottery barn

http://m.domaindlx.com/realtop/pottery-barn pottery barn

10. forex broker - May 20, 2008

forex broker

http://usafinances.free10gb.com/forex-broker forex broker