Agile Test Driven Development (TDD): A Real-Life Example.
Test First is a concept that has been around for quite some time now, and maybe you know it, maybe you don't. There are plenty of sites dedicated to it, but assume you're new to it or better yet, you have to explain it to someone. Well, here's a real life example that will save you a hundred embarrassing moments, and make you look smart, too.
Upon walking into the bathroom, you lean down and look under the stalls and determine that where there are no feet, there's an open seat. You proceed to that stall, and lightly knock on the door, and the door swings gently open. You reach over to the toilet paper roll, and break off a square or two, and then you wipe the seat. You throw the used paper in the toilet and flush the toilet. You turn around, shut the door, and lock it, then unlock it, then lock it again. You remove the necessary garments and place yourself upon the seat and take care of business. You file the required paperwork, flush the toilet, stand up and redress. The normal activity ends here.
Test, what test? You just went to the bathroom?!
As you read the story, I assume you were waiting for a point, but as they say, the devil is in the details. Reread the story, but think about what would happen if some of the actions did not occur or did not occur in the order stated. For example, what if you looked at the seat, determined it clean and didn't wipe the seat with paper?
What you should've learned
in the Story above, here are just some of the tests performed, for what they tested, and what the Pass/Fail result would have been
1. Leaned over foot check - This possibly saves you the embarrassment of knocking on a door that is already occupied. There's no guarantee that the lock on a door works, so if you can prevent knocking on a busy stall, you save yourself that awkward moment. This is barring the weirdo that stands on the seat, but if that happens to you more than once a lifetime, then you need to play the lottery more. Pass: Head towards the open stall. Fail: Head towards another bathroom.
2. Lightly knock on the door - As discussed in #1, no lock is guaranteed to work, so if you just push on the door, and there is someone in there (maybe your vertigo kicked in when you leaned over and you walked to the wrong stall.), you wouldn't want to shove the door open and risk hitting them in the knee, or worse, the forehead, knocking them unconscious, and then you've really got a mess to clean up. The light knock will either pass, and the door will gently swing open, or fail, perhaps the janitor locked the door because the toilet is inoperable, or maybe the toilet isn't even there. (We didn't test for that, we only looked for feet, remember?)
3. You reach for toilet paper. This should be a no-brainer, but how many times has someone asked you for some paper? This simple test alerts you to the fact that there IS paper, prior to ever sitting down. It's so simple, but yet is the least conducted test, and it results in the 2nd most embarrassing possibility. Pass: You continue to use this stall. Fail: You find a new stall and start the test process from the beginning.
4. Wipe the seat - Again, not what we ever want to think about but nothing worse than sitting in something undesired. But, also, what's the oldest college prank in the book? That's right, the old 'shoe polish on the black seat' trick. Even if the seat looks clean, this simple test will prevent the 3rd most embarrassing possibilty, getting got by the boys in the frat house. Pass: You proceed. Fail: You show the boys how smart you are, or if the seat is so filthy that it can't possibly be wiped clean with the amount of available paper, then you keep walking.
5. Throw the paper in the toilet, and flush the toilet - To toss something into a container, one typically looks to where they are tossing. This will visually alert you to an issue within the container. Flushing the toilet will give you the peace of mind that the toilet is operational. I'm sure you've been waiting to read what the number one embarrassing possibility is, and that is flushing a full toilet that doesn't really flush, or worse, doesn't stop flushing. Pass: stay the course, Fail: find another stall.
6. Lock the Door / Unlock the door - As you've learned already, the door lock plays several roles. But, it's not only important that it locks, but that it also UN-locks. Granted if it doesn't unlock immediately there is a remediation that does not affect the remainder of the process, but it's nice to know that ahead of time, such that you can use the remainder of the time available to prepare for an alternate egress.
Don't fail the "Open Book" quiz
In life, there are many aspects that are completely "open book". For example, checking if there is paper, if the toilet flushes, does it overflow when it flushes, and can you get out of the stall when you finish? As you plan your design, development, and/or execution, if you find that you're failing on the Open Book's, then how can anyone expect that you've anticipated the gremlins?
More by this Author
In SharePoint 2010, moving a list item or library document and retaining the version history is easy to do within the Content and Structure functionality.
The file is corrupt and cannot be opened is a false error message, and may be easily resolved by unblocking the file. By Easy Bins Dumpster Rentals of Northern VA.
Finding the Spare Tire on a Chevy Truck is hard enough, but removing it is a little unintuitive. Learn the basics to make your next tire change very easy.
No comments yet.