Slashdot Mirror


Test-Driven Development by Example

PinglePongle writes "Kent Beck is well known as one of the main drivers behind eXtreme Programming -- a style of development which favours a very disciplined but low-formality approach to coding. Writing applications 'test-first' is one of the practices of XP, and this book explores the subject of test-driven development in detail." Read on for the complete review. Test-Driven Development by Example author Kent Beck pages 220 publisher Addison Wesley rating Superb reviewer PinglePongle ISBN 0321146530 summary Kent Beck -- author of the original Extreme Programming book -- explains in detail how to turn your development world upside down by starting with the test, then writing the code.

What it's all about: Test-driven development is about being able to take tiny little steps forward, test that the step took you in the right direction, and repeat. The "TDD Mantra" is red/green/refactor:
  • Red: write a test which will exercise a feature, but which will fail (because you haven't yet written the code)
  • Green: make the test succeed, doing whatever you need to do to get to "green" as quickly as possible -- don't worry about prettiness
  • Refactor: now that you have code which passes the test, eliminate all the duplication

The book then shows 2 fairly detailed examples of a development project (or snippet of a project) which progress using this style of coding. The first example deals with the creation of multi-currency capabilities for an existing project. In the space of 17 chapters, the author walks you through the creation of 6 classes (1 test class, 5 functional classes), complete with the thought-processes behind them. The code is written in java, and is trivially easy to follow, because it gets introduced in tiny little chunks; most chapters are less than 6 pages in length.

The second example is the creation of a unit testing framework in Python. It is significantly more complex and real-world than the first example, but again proceeds in very small steps, and in small chapters.

The final part of the book contains patterns for test-driven development -- practical real-world advice on how to do this stuff for real. Nearly all the "patterns" are phrased as question/answer pairs, and they range from deeply technical design patterns to advice on the best way to arrange the furniture.

What's good about the book? Kent Beck is a very good writer -- his writing is clear, he is not afraid to leave out stuff he assumes you can guess for yourself, but when he does go into detail you feel it is necessary to get the big picture, rather than mere geek bravado. Even if you don't adopt Test-Driven Development, many of the ideas are well worth considering for your day-to-day coding situations.

What could have been better? The book stresses the importance of taking 'little steps,' and sometimes you feel impatient to move to more challenging tests before properly finishing the current chapter. I was also hoping for more of a discussion on the practicalities of unit testing database-driven systems, where you frequently have to test business entities which are closely coupled to the database.

Summary If you code for a living, or manage people who do, you should read this book -- it's a quick enough read -- and consider some of the assertions it makes. If you feel you're introducing more bugs than you expected, if you feel uneasy about how close your work matches the requirements, this book gives you some powerful ideas. You can purchase Test-Driven Development by Example from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

40 of 189 comments (clear)

  1. I always test drive my apps by Amsterdam+Vallon · · Score: 5, Funny

    Although it sucks to lose 20% of your code when you drive it off the lot.

    --

    Reply or e-mail; don't vaguely moderate. Ex-O'Reilly/MIT employee, now a full-time Google employee.
  2. hopefully... by EnderWiggnz · · Score: 2, Redundant

    hopefully, this will last as long and have as big an impact as extreme programming did.

    for the sarcasm impaired : this is sarcasm.

    --
    ... hi bingo ...
  3. Good by giel · · Score: 2, Insightful

    I think we must try to get rid of wanting to design and plan every little thing in front and then find out stuff doesn't work ending up running out of time and in the end having noone willing to pay for all useless efforts.

    Although many people don't believe in XP it is a way to accomplish development in such a way you do get deliverables. Maybe it does not improve speed but it does improve quality and reduce risk.

    So any book which is able to explain the pro's of XP and open eyes of non-believers is good.

    --
    giel.y contains 2 shift/reduce conflicts
  4. What the XP folks have right (and wrong) by thac0 · · Score: 5, Insightful

    The reason some XP projects are successful is because they actually have testing as part of the game plan. It is *shocking* to me, having been in the industry for better than a decade and pounding code for 20 years, the state of testing in corporate america. Just atrocious.

    There are many labs that don't test at all, and a vast majority test poorly. I've worked in some fortune 500 labs that didn't test at all. Scary stuff. Nothing life threatening, but all of a sudden I wasn't so convinced that the reason my account was misconfigured was because *I* gave wrong data. Simply bug riddled. Those that do test often do so manually. Forgetting for a moment that humans are likely to take short-cuts and not bother to execute tests they perceive to be out of the scope of their recent change, they are failable. Of course they are, that's how the bugs got there in the first place.

    So, the XP folks have the testing thing down. They test before the code is written, and their tests are automated.

    Then they take leave of their senses. The claim that because they've successfully turned one idea on it's head (i.e. testing *first*) that they can turn others is ludicrous. Design first is still valuable guys. I've eliminated thousands of bugs simply by having the right design to begin with. Waiting until you've cobbled something together that passes the test and then hoping that your boss will allow you to refactor is a loser. If it weren't Scott Adams wouldn't be a millionare.

    So, write your tests first. But do your design before you code, not after you've put together a thousand lines of crap.

    --
    poliglut.org: they're still alive and fighting the man
    1. Re:What the XP folks have right (and wrong) by Lumpish+Scholar · · Score: 4, Insightful
      ... some XP projects are successful is because they actually have testing as part of the game plan.... the XP folks have the testing thing down.
      The best thing about XP is that, with the possible exception of test-first (a.k.a. test driven) development, none of the practices are new and original. I mean that in the best possible way! All the practices are tried and true, based on experience long before Kent Beck was using the word "extreme" this way.
      Then they take leave of their senses.... Design first is still valuable ...
      "Design" in the pure waterfall sense -- do 100% of the requirements before doing any of the design, do 100% of the design before doing any of the coding -- doesn't scale up to large projects or rapid development. It's important to use an iterative approach: do a little analysis, do a little design, do a little coding, do a little testing, repeat until done.

      XP breaks the design/coding/testing cycle into very small iterations, each one as big as one automated unit test case. It's a very exploratory style of software development. XP doesn't mandate any high-level design artifacts (though it doesn't forbid them either).

      What none of the XP books say is that developing unit tests is a design activity, and the unit tests are design artifacts! Unit tests outline the responsibilites of classes, in the original responsibily-based style of object oriented design.

      XP programmers do design on whiteboards, and in their heads. Some of these artifacts are lost. Some would have become obsolete in a hurry. (The unit tests are guaranteed not be obsolete, at least as long as they're passing.)

      I'll take that, any day, over a hundred pages of out-of-date UML diagrams.
      --
      Stupid job ads, weird spam, occasional insight at
    2. Re:What the XP folks have right (and wrong) by dubl-u · · Score: 2, Interesting

      So, write your tests first. But do your design before you code, not after you've put together a thousand lines of crap.

      If you've written 1000 lines of code before you refactor, you're waiting way too long. I do little refactorings every few lines, and bigger ones whenever things don't look right.

      Look at it this way: you can do your design before you code, while you're coding, or afterwards. The waterfall advocates about 80:20:0. But that assumes that you learn nothing, think of nothing when coding. That's stupid; instead, what people do is grumble and imagine what they'll do in the next version.

      Now that I'm doing test-driven development, my ratio is about 20/30/50. I still do some design up front, and that's very valuable. But instead of having those raging arguments about what design might work best, we start building and find out, refactoring towards the best design as we go.

      Waiting until you've cobbled something together that passes the test and then hoping that your boss will allow you to refactor is a loser.

      If a boss is such a micromanager that he's telling you which lines of code to work on every 15 minutes, then it's time for a new job. The people I work for recognize that I'm a professional and trust me to tend to my business, especially given how willing I am to explain it to them.

      When bosses ask about refactoring, I explain that we do it so we can go faster. If they think it's a net loss, then I am always glad to prove them wrong: if they want to measure productivity each month, we can see which way works better.

      Think of it this way: not refactoring is like not exercising: you get slower and slower, everything gets creaky and unreliable, and you die sooner because your arteries are clogged. A little regular exercise keeps you healthy, limber, and active.

  5. too many developers by netsavior · · Score: 2, Insightful

    it would be nice to have 2 developers for every problem... but that is never going to happen.

  6. Haven't we... by Some+Bitch · · Score: 5, Funny

    ...been doing this for years anyway? My code development cycle has always been... 1. Write code to use function/procedure. 2. Write function/procedure. 3. If function/procedure==fucked return to 2 and unfuck. 4. Once it works, tidy it up. Now it appears someone else has added steps 5 and 6... 5. Write a book about it. 6. Profit!!!

  7. Dibert and eXtreme Programing by QEDog · · Score: 4, Funny

    What would Dilbert do?

    Here and here!

    I love buzzwords with X anyway...
    --
    "There is no teacher but the enemy."-Mazer Rackham
  8. Buy PEAA, too by Amsterdam+Vallon · · Score: 2, Informative

    You can get Martin Fowler's "Patterns of Enterprise Application Architecture" in a bundle bargain at Amazon along with Kent Beck's "Test Driven Development" for $79.98 [link to PEAA bundle]

    --

    Reply or e-mail; don't vaguely moderate. Ex-O'Reilly/MIT employee, now a full-time Google employee.
  9. Is XP good? by timeOday · · Score: 5, Interesting
    Now that XP has been "out there" for a while, does anybody have some war stories?

    Does the reliance on incremental development and refactoring rather than a intricate, up-front design really work, or result in a big wad of band-aids?

    Is pair programming OK, or do you sometimes get stuck with the nitpicker from hell who has to have every detail his own way?

    Is close involvement with the customer good, or does it just give them daily opportunities for endless bright ideas that prevent convergence?

    Just wondering...

    1. Re:Is XP good? by silkySlim · · Score: 3, Insightful
      I can't speak for XP specifically, but lightweight development has been nothing but a positive experience for my team. But it's a tricky question. Because if you truly believe in the "Agile" methodologies, you find that the development process quickly becomes customized based on your team members and type of project. It's all about creating the path of least resistance for your team while still moving towards the end product.

      I work in a game studio where our last project had 6 months of pre-production time. We generated reams of technical design documents. The intention was good, but they were never maintained or even referenced after their initial creation. We just said "documentation is necessary" and it needed to be done. In production, the team wasn't on the same page. Every programmer had a task list they just milled through. The assumption was the initial requirements won't change. The result was ugly. The product was subpar and a couple months late. Everyone was miserable. It sucked.

      I'm currently leading a new project here. We're 6 months into production and every milestone has been delivered ON TIME and accepted by our customer. The team is focussed on the current milestone, there isn't a lot of process to get in the way. The best part is, writing code is fun again. We don't have goals we can't accomplish. And we fully expect the product requirements to change during production.

      I could get into specifics about our process. But I don't think it would be that helpful. I think specific methodologies like XP are guidelines to get you started. From there, you really should re-evaluate your process frequently (a fundamental excercise to be "Agile") and make changes as necessary. Kind of like optimizing your code.

      The following links gave me all the information I needed to devise an initial process plan (which included TDD). But once it was put into practice, it naturally evolved into the process we have now (which doesn't include TDD)...

      The New Methodology by Martin Fowler

      The Agile Manifesto

      Agile Software Development Ecosystems by Jim Highsmith

      I also suggest reading the chapters on "thematic milestones" in Writing Solid Code.

    2. Re:Is XP good? by spstrong · · Score: 2, Insightful

      Now that XP has been "out there" for a while,
      does anybody have some war stories?

      It's interesting. The "war" has been with management. We showed our Project Manager a couple of the books (he actually READ them) and we were allowed to use XP. After our first project was successful, we have been trying to get official approval to develop using the methodology and it has been tough.

      Does the reliance on incremental development and
      refactoring rather than a intricate, up-front
      design really work, or result in a big wad of
      band-aids?

      As with any approach the team must be disciplined to
      1. Test First
      2. Talk to each other
      3. Ask for help when needed
      4. Refactor mercilessly
      5. Code the simplest thing that will work

      You will probably say "of course!" to all of the above, but if you don't stay disciplined within the team, you will get into trouble.

      Is pair programming OK, or do you sometimes get
      stuck with the nitpicker from hell who has to
      have every detail his own way?

      Pairing is great. If your goal is not well written simple software, you are not part of the team. You are the cowboy who is the reason the team is all working on Saturday to fix the sh*t you went off and wrote by yourself! (Ok, Ok, breathe....)

      Is close involvement with the customer good, or
      does it just give them daily opportunities for
      endless bright ideas that prevent convergence?

      The customer wants an application as quickly as possible. They have a business need and don't want to have to wait 4 more months for their great ideas to be implemented. If they continue to think off the top of their heads, they probably didn't know what they wanted in the first place and it will take that extra 4 months to get it out of them and get it into the application anyway.

      XP works. Our teams are 4 or 6 programmers with a tester. When we test first and give the tester something to test that is not fragile, we get much farther much faster than "code it and throw it" at the tester and hope it works.

    3. Re:Is XP good? by Anonymous Coward · · Score: 2, Interesting
      War Stories you want? You got it!! By the way, I am going as Anonymous Coward 'cause I can't say anything negative about the company. The company shall also remain anonymous. We tried it and it worked. However, it did not work well. The primary reason it did not work well was that the concepts were not consistently enforced. Also, upper management forced it on us as the next great thing and then proceeded to do things in the same old way.
      • We had a project and a project lead who developed the stories.
      • A customer is supposed to develop the stories. The customer tells you what is needed and you develop that, and only that. Stories are small pieces of functionality that can be developed in a few (three to five days). One of the mantras is that the stories have to be short.
      • We had problems with the project lead writing stories and then changing them in mid-stream.
      • There is nothing wrong with the project lead re-writing the story. However, our project lead would re-write the story without allowing the developers or testers to re-factor their development time.
      • We had problems with the lead developer including functionality because the customer will want this down the road.
      • One of the primary rules is that you code the story and only the story. You do not add in functionality that you thing the customer might want.
      • We had stars and gurus that were allowed to work alone rather than as part of a team.
      • Another rule is that all production code is developed in pairs. This is for mentoring and learning as well as having two sets of eyes looking at the code to notice the missed comma or semi-colon. You pair an experienced programmer with one less experienced so the less experienced programmer can learn.
      • We had tests written to test the story, and tests written to test what the customer really wanted.
      • We wasted time testing the additional functionality as well as wasting time coding the additional functionality. It also, agin, violated the XP rules.
      • We had stories that took three days to code; the tests to verify the story took two weeks to code.
      • This was, in most cases, an extremely valid time requirement. However, upper management and the project lead refused to allow the time. The statement was made repeatedly that it shouldn't take that long. Again, this violates an XP rule. The customer tells the team what is needed and developers tell the customer how long it will take to code the story. The testers tell the customer how long it will take to code the test. Management, the project lead, and the developers, as a whole, were of the opinion that the test should not take any longer than the actual code. This resulted in the testers working overtime on a near-continuous basis.

        Then, after several months (almost a year) of developing the XP way, the company had to have a demonstrable product within the next two weeks. In the end, nothing mattered except the ol' bottom line. We had to go to market to beat a competitor. It did not matter that we still had nine weeks of stories to finish the project. It did not matter that tests were failing. It did not matter that the kernel and OS version had changed twice in the year, each time causing the developers and testers to re-visit, re-test, and re-code a large part of the existing code.

        A nice shiny package was not ready exactly when the suits wanted it and the company shut down the devision, moved everything to another state and other developers. The product still has not gone to market, but the company got rid of the developers and testers that didn't deliver.

        Lest you think this is sour grapes, I actually think XP practices can work for what it was intended; small project development.

        Ours was a major undertaking with an entirely new product. There was education and training necessary that was never taken into consideration as far as the project timeline was concerned. We also had to learn new hardware technology, operating systems, development and testing languages at the same time we were learning XP methodology.

        It was not fun!!
    4. Re:Is XP good? by dubl-u · · Score: 4, Interesting

      Hi! I've been doing XP on and off (depending on client preferences) for a couple of years.

      I'm immensely happy with it. It's not a magic bullet, but gives me the tools to solve a lot of common problems.

      Does the reliance on incremental development and refactoring rather than a intricate, up-front design really work, or result in a big wad of band-aids?

      Yes, it works. It takes a bit to learn how to do it well, but it works.

      Indeed, in some ways, it works better. When I did most of my designing up front, I had to guess about a lot of things. Now I'm a pretty good guesser, but I'm not perfect. And since I knew I was making designs that I had to live with for years, I tended to play it safe, putting in things that I would probably need someday. I hoped.

      Now, I don't put anything in until I know I need it. This keeps the design cleaner, and saves me all of the time I would have spent on bad guesses and things obsoleted by changing requirements.

      Is pair programming OK, or do you sometimes get stuck with the nitpicker from hell who has to have every detail his own way?

      I like pair programming a lot, and more people are good at it than you would expect. But some people are indeed pains in the ass; just last week we had to sit one guy down and have The Talk with him. If he doesn't shape up, he can go be a nitpicking cowboy on somebody else's project.

      Right now I'm also doing some solo work, and it really suffers from the lack of a pair.

      Is close involvement with the customer good, or does it just give them daily opportunities for endless bright ideas that prevent convergence?

      It can work really, really well. The trick is that you must let them steer the project, so that they can see that asking for all sorts of random stuff means that their precious project will be screwed.

      For example, I and another fellow were recently called in to work on a project that was six weeks from delivery and running late. The product manager handed us a one-page spec, spent 30 minutes showing us the existing code and said, "So can you do that in time?"

      Now the only honest answer was, "I dunno, but probably not with all that you've asked for." But we walked him through the XP practice known as the Planning Game, where we broke his requirements down into bite-size chunks, wrote them on index cards, and then he ordered them by importance. There was far more work than could be done in time.

      So then we asked him to draw a line at the point which, if we didn't reach it, he would slip the date, and if we did, he would ship. It cause him great pain, but he did it. Then we agreed that we would start developing and see how things were progressing.

      As time went on, he, like any client, had all sorts of great ideas, and so did we. Every one got written on a card, and we asked him to place them wherever he wanted in the stack. This forced him to make tradeoffs; the more stuff he put in before the release, the farther away the release would be.

      When the six weeks were up, we shipped a product with less than half of what he originally asked for. But instead of being pissed, he was happy! He got the half that was most important to him, and he was the one who made every choice about scope, so it wasn't our fault, that was just how things were.

      And best of all, because we'd stuck to the XP practices and done extensive testing, there have been no bugs reported against our code. With code that solid, we're glad to start extending it, instead of the usual pattern where a big deadline push means the code is crap.

      So yes, I like XP a lot. I get to write good code, polish the design, and have good relationships with the business folk. It rocks!

    5. Re:Is XP good? by jjl · · Score: 2, Insightful
      > Is pair programming OK, or do you sometimes get stuck with the nitpicker from hell who has to have every detail his own way?

      The team should create a common guidelines specification which then must be agreed by everyone in the project. After that nitpicking to make stuff conform to the guideline is a good practise, since sticking to the agreed style is an improvement.

      --
      --
  10. if you're organized by Anonymous Coward · · Score: 2, Insightful

    Isn't that the whole crux of XP? If you're not organized, nothing will help. If things are organized, but need tweaking, then XP can be beneficial. Having the pre-requisite of having some organization to how software is developed is the hardest part. If your PM isn't organized and you're not organized, forget about it. If you're organized, then you're probably already doing unit testing in some form.

  11. Write code to determine if your code is flawed... by Dareth · · Score: 2, Insightful

    The idea of breaking your program into small parts and testing them is fine. Writing programs to test these parts seems to be a bit problematic. I wrote a test program to test this module. But then I remembered that I forgot to write a program to test the test module! You use your specifications to write your module, then you test against these specifications. If you write a program to test these specification, then you already must have a firm grasp of the specifications. What assumptions about your module are you making when you write your test? Or is this a simple black box type test where you do not care how it works inside? Any faults that you have in your conception of your test program will be carried over into your module, or worse your module might be correct but your test program flawed. Seems like an extra layer of complexity rather than a useful method. I also dislike the do it dirty and fast, then refactor part. Proper planning and implementation seems the better approach to me. I understand that "mad hacker" instinct to dive in and code away, but that has to be restrained a bit when the complexity of the problem rises.

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
  12. In Other News... by Mazurbul · · Score: 2, Funny

    The RIAA issued a press release saying that they are initiating a lawsuit against Kent Beck because eXtreme Programming principles could lead to faster development of file-sharing software. The RIAA's main argument is that CD sales are falling at levels that could only be explained by eXtreme Programming.

  13. Moving beyond XP: XXP by Waffle+Iron · · Score: 5, Funny
    XP testing techniques are great in theory, but there is still a gaping hole: if your tests aren't correct, your program could still end up flawed.

    That's why I've moved on to XXP, which focuses first on correctness of tests. First, I write a test that tests a test. Then I write the test. I test the test until the test tests ok. Then I write a test for another test, and so on.

    My pair programming partner is currently working on an idea he calls "XXXP". I'll post our results if we ever finish a project without getting lost in infinite recursion.

  14. Is there anything here for the GUI developer? by kahei · · Score: 3, Interesting


    I'd be the first to admit that XP offers a lot of risk-reduction -- for teams that are working on things that are easy to unit-test.

    With a class that is supposed to take in a bond and output the yield curve, it's easy to write a unit test. But what about the next class, that renders the yield curve on the screen? What about the complex, distributed system of Excel objects and forms things that draw a network and things that flash green and go 'ping' to indicate a change, that are equally necessary but generally much harder to write and much more likely to go wrong?

    Has anyone tried to apply test-first programming to complex guis? I can't say that any obvious way to do it has ever occurred to me. Worse yet, when I ask I generally find that people either

    a) Are in the same position as me, or
    b) Believe that a GUI is a little thing you spend a couple of days on after you finish the application

    So, for now XP is something I read about rather than something I actually do.

    --
    Whence? Hence. Whither? Thither.
    1. Re:Is there anything here for the GUI developer? by JohnFluxx · · Score: 2, Interesting

      All my GUIs seem to collapse on themselves, so I'm in no position to talk...

      However :), what I _do_ like are programs where you seperate the code and gui as much as possible. Even to the point of making them seperate programs or at least a library.

      Pros:
      You can have many different gui's - personally this is how I like cross platform gui's done - one tailored for each platform.
      If it is a seperate program, then you can script it, right from the start too.
      You can test the code easier, since there's the gui is seperate.

      Cons:
      For some reason having them seperate seems to make them less robust in the examples I've seen.

      So er yeah anyway. One solution is, as above, seperate your gui and code. Another solution, perhaps, is to plan all your dcop calls (or whatever your favourite scripting thing is).
      This ties in nicely in nicely with your use case diagrams since you can have calls for your "stories".

      I'll shut up now.

  15. Success Stories? by Lucas+Membrane · · Score: 3, Informative
    A few years ago, the XP promoters were bragging about the Chrysler Compensation System, the first big XP project. They were redoing all of Chrysler's payroll systems, they were part done, they were succeeding where much larger efforts had failed, and the new managers from Mercedes wanted them to finish it so that they could go on and apply XP to other problems.

    Last I heard, the Chrysler Compensation System was not finished, scrapped prior to going into production. What are the more recent projects that demonstrate how well XP works?

    1. Re:Success Stories? by Joseph+Vigneau · · Score: 4, Informative
      Any ideas why it failed?

      Hear it from the players players themselves.

      One of the benefits of XP is that it can tell you much earlier about whether or not to terminate a project in the first place. From Extreme Programming Explained:

      One of the features of XP is that customers can see exactly what they are getting as they go along.
      -- Kent Beck
  16. Re:sounds great but... by Peyna · · Score: 2, Interesting

    XP has worked in some small scale applications pretty well. It isn't for every project or every person, but in some cases it can be very effective, and in others (as you stated) it can be a disaster.

    I think it's great that there are new ideas for ways to develop software, (although XP is actually fairly 'old' in computer science terms). There is no magic formula for producing quality software in a reasonable amount of time yet, but XP is another step in the right direction.

    Note: While XP's entire methodology wasn't written down until about 1996, many of the ideas that it uses had been in circulation since the 70s.

    --
    What?
  17. Do we need a book for every rule of XP? by Anonymous Coward · · Score: 3, Interesting

    What? Is he going to write a book for every rule of XP?

    Testing is important, but XP testing philosophy is a catch all for actually thinking about your product and the purpose of you product. XP is about making hack programmers look legit. XP has some good points, such as an emphasis on simplicity, testing, and customer satisfaction, but mostly it's about making bad habits look good, like no design and iterative feature hacking with ignorance to the bigger picture of the app.

    Some design up front is important. Documentation is important. Code ownership is important to an extent. In a medium to large system, having everyone able to change any line of code is just stupid. People change shit and don't have a clue why the code looks the way it does. One of the arguments for no code ownership is that a lead architect can't keep it all in his head. Well, what about a team of that consist of many folks that aren't as capable as that lead architect? they are able to comprehend the whole system according to XP. And, they are allowed to change whatever they want, when they want. So, get a couple of average programmers with large egos, and you have a lot of problems.

    XP is great for people who are happy doing bug fixes all day instead of avoiding the bugs to begin with. The assertion that XP results in less bugs is pure speculation and from my experience, a very misleading claim. Just because your test succeeds doesn't mean that your program is correct. And if the test is the only glue validating the success of your final solution, you're screwed.

  18. just another way of designing by WPIDalamar · · Score: 2, Insightful

    It sounds to me like this is just another way of designing, but that makes the wrong emphasis. These tests sound a lot like low level use-cases. You should be creating those anyways. But you should create all of those first! Not one at a time as you code.

  19. Re:sounds great but... by Lumpish+Scholar · · Score: 4, Insightful
    I just can't stand other people nozing around in my half completed code ...
    Then you ought to (1) try the other XP practices before you try pair programming, and (2) learn how pair programming really works!
    ... the extreme attention to testing ...
    You don't think testing is important???
    ... and the team-spirit you ought to have ...
    Check out the work of James O. Coplien. He's an extremely hard core C++ guy, but when he was doing research at Bell Labs, he descovered that organization effectiveness was far more important for software development productivity than any technological advance.

    I once worked at a start-up where someone started on Monday, and never came back after Wednesday night, leaving a voice mail message that said, "You never told me I was going to have to work with other people!"

    You're going to have to work with other people. The better you work with them, the better you work, the better everyone works. (Hugs not required.)
    --
    Stupid job ads, weird spam, occasional insight at
  20. Tests are only as good as your requirements�. by (H)elix1 · · Score: 3, Insightful

    Requirements are the Achilles heel of XP. Without rock solid requirements, you are just guessing for the test scripts.

    Take a trivial example -- an entry form for a phone number. What is a valid phone number? Add in real world things like extensions, folks using alphanumeric substitution (1-800-DISCOVER), and internationalization and it gets interesting. Now a test driver is not that big of a deal if you know what to put in it. From a design standpoint, it would really be nice to have solid requirements and test scripts that provide concrete examples as to what the business was asking for. Real world? I could only dream for mediocre requirements that might resemble not only what they asked for, but what they want.... At least enough to try and read their minds.

    1. Re:Tests are only as good as your requirements�. by mikemulvaney · · Score: 2, Informative
      I think you are missing the point. You seem to realize that you are never going to get rock solid requirements, which I think most people would agree with. But then you use that as an excuse to throw away XP?

      Test Driven Development is a great way to deal with changing requirements. For a phone number validator, you would write up tests for all of the initial requirements:

      testLocalNumber()

      testLongDistanceNumber()

      testTenDigitLocalNumber()

      testAlphaNumericNumber()

      Then when you deliver the application and find out that you need to deal with international numbers, you write:

      testInternationalNumber()

      You get a red bar, beacuse you can't handle i18n numbers yet. So get that working, and when you are on a green bar, then you know that it still works for all those US numbers and it works for the new foreign numbers.

      Then you extend as you get new requirements:

      testEnglishNumber()

      testFrenchNumber()

      testItalianNumber()

      What is the alternative to this? You are still lacking requirements, even if you aren't doing TDD. But you wouldn't have any tests, and you wouldn't know exactly what your class can do for you.

      Test Driven Development is not all about leaving test artifacts. The tests are constantly changing during development as your requirements change. The main idea behind TDD is to program from the client side of things first. This is similar to the idea of writing documentation first, with the added benefit that as you finish the tests, you prove that the class does what you want it to do.

      -Mike

    2. Re:Tests are only as good as your requirements�. by dubl-u · · Score: 2, Insightful

      Requirements are the Achilles heel of XP. Without rock solid requirements, you are just guessing for the test scripts.

      Spoken like a guy who has never done XP.

      One of the core requirements of XP is known as the On-site Customer. This means that there should be somebody at all the meetings and sitting within shouting distance of the programmers, somebody who can answer questions like that or find out the answers. (In some companies this person is called a Product Manager; in others a Business Analyst).

      I could only dream for mediocre requirements

      Yes, requirements documents are generally silly. That's why XP doesn't use them. Instead of waving around some phone-book sized pile of garbage, XP practitioners use high-bandwidth, low-latency communications techniques: they talk. And they try out new versions of the software every week.

      At least enough to try and read their minds.

      Yep! And get yelled at when it turns out you don't have psychic powers. 'Cause that's what it takes to make standard development practices work. Isn't that a sign we should try something different?

  21. Book Draft is available online by Googol · · Score: 3, Informative

    here, [pdf,yahoo.com] with more information here[vt.edu].

  22. My (mixed) experience with test-driven development by Lumpish+Scholar · · Score: 3, Insightful

    I've done a little test-driven development on my own.

    Test-driven development seems to call for a series of baby steps, each corresponding to a unit test case. Unfortunately, I wasn't always able to identify "the next baby step"; even if I could pick what I thought was the next unit test, I sometimes found myself spending far too much time, and writing far too much code, for just that next test.

    I also sometimes found that "the next test case" already passed. I don't know if I wrote more than I needed to early on, or I picked the wrong next case, or if there's more to all this than I've picked up.

    When I was in good TDD mode, I was flying; test, red, code, green, refactor, green, next! It's a very rapid, and very intense, experience. There's a reason XP usually calls for a 40 hour week; by the time you're done with a few hours of this, you are tired! (But you've gotten a lot done.)

    --
    Stupid job ads, weird spam, occasional insight at
  23. Re:XM by giel · · Score: 2, Insightful

    IMHO you mix things up, sorry.

    eXtreme Medicine -> not so eXtreme Programming:

    (in general use a lot of blahblah and don't show what you're doing)
    make a big picture of all what's wrong
    try to fix everything at once (dripping nose, broken legs, breast enlargements, etc)
    determine whether or not thing have gone well is the patients problem (hey my?? oh, cute, well let's make em even bigger)
    leave your patient, with a lot of (new) problems


    not so eXtreme Medicine -> eXtreme Programming:

    (in general use a little blahblah and show what you're doing)
    focus on the most important issues (broken legs)
    make sure you can see if it's fixed
    fix the most important issue, and continue with the next important thing (dripping nose)
    disencourage breat enlargement


    Yes, it means that you need very good developers for XP. These people must be able to do good designing to have the big picture in mind and they must be able to judge quality.
    Do they exist? Yes...
    Many? Enough, but there is an awfull lot of very crappy developers out there.

    --
    giel.y contains 2 shift/reduce conflicts
  24. Re:sounds great but... by October_30th · · Score: 4, Interesting
    You're going to have to work with other people. The better you work with them, the better you work, the better everyone works. (Hugs not required.)

    I couldn't agree more.

    I can't think of many jobs - at least for college/university educated people - that do not require soft skills like ability to work with your coworkers and communication (meetings, presentations, acting as a tour guide for VIPs, etc.).

    I used to hate having to deal with other people any any way. In fact, that was one of the reasons why I decided to embark on a research scientists (Physics) career. As a scientist I wouldn't have to deal with people, give talks, socialize or - most imporant of all - end up in any kind of a manager/boss line of work. I would just sit, think and write papers. That's what I thought and boy how wrong I was.

    Most science, and experimental physics in particular, is done in groups. There's no way around it. You can't run a lab alone so you need to have people around you. Even as a postdoc you have to be able to hire good PhD candidates and supervise them. You have to be able to interview them, understand what makes each of them tick at workplace and how to manage them to get the best out of them.

    Then, unless your lab is established and extremely well funded, staffed and equipped, you often need collaboration from other groups. Making contacts with other scientists and establishing mutually beneficial collaboration requires publicity (talks!), diplomacy (socializing!) and patience.

    A person who cannot work with other people simply does not fit into this environment. No matter how brilliant scientist he is, without the social skills he is very likely to turn out as nothing.

    I still get slightly nervous when I have to a give a talk. I still don't like meetings. However, I have grown fond of managing people, because, as difficult as it sometimes can be, it's a wonderful feeling to see your highly motivated and skilled people working with you in harmony. The older I get the more I appreciate social skills over raw intelligence or mathematical/logical ability. If it all comes in one package, jolly good. However, if I had to choose between a budding physics genius with a highly abrasive personality and a slightly well performing person with good social skills, I'd choose the latter. No question about it.

    --
    The owls are not what they seem
  25. XP == Xtremely Pstupid by copyconstructor · · Score: 2, Informative
    One day my manager came and suggested we try XP. So I did what I normally do in such situations and did a search on the pattern [stupid management suggestion] +stupid and quickly turned up what I was looking for:

    http://http://www.softwarereality.com/lifecycle/xp /case_against_xp.jsp

    In two minutes I was able to save both myself and my company many man-years and headaches.

    1. Re:XP == Xtremely Pstupid by copyconstructor · · Score: 2, Informative
  26. scrum methodology plus xp == happy developers by maharg · · Score: 2, Informative

    I work for a largish (the largest?) media organisation in the world cutting code as part of a team of 4 developers plus a senior developer.

    We've been using Scrum and Test Driven Development for about six months now, and there is NO WAY I'm ever going back to writing code without writing tests first.

    Scrum (see http://www.controlchaos.com) is a "lightweight" development methodology. It's developer driven (no more gannt charts !!!!), and it's agile, meaning that it embraces change throughout the project lifecycle. I can highly recommend it. But I digress...

    Test Driven Development is something that every halfway serious programmer should be doing IMHO. It doesn't replace the initial back-of-a-fag-packet design stage, nor does it stop you designing elegant and effective architectures. What it does do is:

    • force you to define rules that your code must obey by requiring that you write tests first. This really is useful, because it makes you think about the implications of how your application behaves.
    • facilitate unit testing - you know that every function, procedure etc works as expected, and fails as expected.
    • facilitate regression testing - when you change / enhance / refactor or otherwise modify your codebase, you know that you have not broken any existing functionality, because you will re-run the test suite against the modified code. Of course, you will have added tests for the new / changed functionality before having coded the new / changed functionality.
    • focus your mind on developing the required functionality - when all the tests pass, it's time to stop coding. No temptation to just tweak a line of code. Careful with that axe, eugene.

    So I can recommend TDD. Check it out. By the way, we're coding mainly in python with some java thrown in too.

    --

    $ strings FTP.EXE | grep Copyright
    @(#) Copyright (c) 1983 The Regents of the University of California.
  27. Re:sounds great but... by jstoner · · Score: 2, Insightful

    Check out the work of James O. Coplien. He's an extremely hard core C++ guy, but when he was doing research at Bell Labs, he descovered that organization effectiveness was far more important for software development productivity than any technological advance.

    This is exactly the point the XP people are missing. All the practices they prescribe require a very sound organizational culture. Unusually sound. If you already have that in place, then XP might enhance your organization's performance. But if you already have that in place, you've already solved a long list of much harder problems.

    And don't get me started on the requirements gathering end of the process: in full XP, you have to collaborate tightly with your business stakeholder folks. You have a problem with the other developers in your own department? Wait till you have to deal face to face with the idiot from marketing or the arrogant ass from finance. A lot.

    --

    'In knowledge is power, in wisdom humility.'
  28. Re:sounds great but... by chromatic · · Score: 2, Interesting

    On one project, we had a bug that would always cause a segfault at shutdown. No one had ever been able to track it down -- it wasn't hurting anything as far as we could tell, but it was highly annoying. This was a very small shop and we were just starting XP (or any determinable development process, for that matter), so we hadn't been doing much in the way of pair programming anyway.

    Myself and another developer tried pairing to find the bug. We talked it out briefly, and decided to do a binary search of the code with print statements (as the debugger couldn't find it). We'd start the program then exit it, trying to find where in the shutdown process the bug was.

    We went over the logs together, and the first person to narrow down another potential location. I'd suggest a spot and add a print statement there, then he'd suggest one. We'd then run the program again, collect our logs, and start over. If I got stuck, he'd have an idea and vice versa.

    It took us about ten minutes to track it down and figure out exactly what was going on. I'd spent a couple of hours on it alone without making any progress before, and I think he'd done the same. If we'd paired on that before, we'd have saved a bit of time and money.

    I'm not sure where you get the idea that pair programming is having some slob sit behind you and breathe over your shoulder. In my experience, it's like having a conversation about code that produces working code. If you can give up the idea that you have to be right and that your way is the best way and, for goodness' sake, hand over the keyboard about half the time, you'll probably find it's a lot more productive and even more fun than working alone.