For Forge 2.0 I've embracing unit testing (JUnit) and I'm writing tests for each method. In the first version of Forge I just wrote code like a madman and only debugged my code if there was a problem. The only part of the code that I tested extensively was the code that handled paying the mana costs. The code kept braking on unusual mana costs like GGG so I wrote a whole truckload of tests in order to test the code backwards and forwards.
Even though part of me still thinks writing tests is a waste of time, it does feel good to KNOW that your code works. The tests should also help refactoring because you can change the code and then run the tests to see if the new code really works.
Unit testing also encourages programmers to write small methods that do one thing well. Small well-named methods are the backbone of any project.
Monday, January 11, 2010
Subscribe to:
Post Comments (Atom)
2 comments:
when you want to refactor your code to improve one method, unit testing is a must. Its kind of an insurance that what you are modifying keep the same functionality as what was there in the first place.
Insurance would be a good thing because I'm used to "programming without a net". I'm still not used to writing the test BEFORE writing the code.
Post a Comment