Coding Fun

I was coding at work the other day and was having a great time. Things were moving fast, and no roadblocks were coming up. Then I asked myself : what's the difference between what I'm doing now and what I'm doing when I do when I'm not enjoying a coding session (other than the fact that I had no major roadblocks appearing)? The answer was pretty clear. I was writing tests first! It wasn't always easy; often it's difficult to think about how I should test a certain functionality when I haven't even designed a solution or written the method or section of code...but it usually pays off afterwards, when I know exactly what is required by the caller/user (should be in the test) and I've already come up with an interface for the functionality (designed by writing the test). After that, all that's left for me to worry about is solving the problem and turning that nasty red 'test failure' light to a bright, tangy green. Just the fact that green and red are used to symbolize passage/failure makes coding more interactive and fun - you get instant feedback on your work :p So the next time you find yourself bored or annoyed while programming, grab your required version of the xUnit framework, and write a test...then make it compile and fail....and then make it pass! It can be the difference between a :D and a >:(


Popular Posts