The path to developer happiness: Unit testing in Python & XSLT
2009-02-12
When David Flanders asked me what I'd like to talk about at the Developer Happiness Days, I thought I could do something on XSLT – which turns out to be not that much of a hot topic – I ended up giving a short talk on XSLT and where to use it and where to not use it, and contributing to the Python day. In both cases I pushed the idea that beginners should start with test-first unit testing.
In the Python day we had a discussion about Integrated Development Environments and concluded that there is no one way, but Eclipse does seem to be popular (Ron Ward and I loathe it but others in our team use it happily). Someone pointed out to me that Eclipse is really good for multi-language development.
I did a quick demo of Doctest which is a way of embedding unit tests in documentation.
What's a unit test?
In computer programming, unit testing is a software design and development method where the programmer verifies that individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method, which may belong to a base/super class, abstract class or derived/child class.
My contribution was a hello world program where the testable bit was a 'hi' function.
(And we didn't really say this but everyone I spoke to was in favour of developing with Unix based OS, meaning OS X or Linux (Ubuntu is the default now). If you're stuck with Windows then get some virtualization going.)
And here are my notes for the lighting talk on XSLT:
Places I have used XSLT follow.
Summary:
-
Don't overdo it.
-
Use it where the overall structure of you input and output is either very congruent or very simple.
-
Write tests first.