One of my recent assignments has been to come up with a presentation for our software engineers about the benefits of using unit-testing in their code and demonstrating how it should be done properly. Easier said than done. How can you explain, to inherently, professionally lazy people, in an hour and 20-30 pages of Powerpoint (or Apple Keynote :P) things that are mostly intuitive and come only with experience, as well as from reading a whole bunch of books + examples and then doing it every day, for each piece of code?\r
\r
It\’s been a real challenge and I was still thinking if I should give up, when I ran into this wonderful piece of code on TheDailyWTF: \r
\r
\r
\r
and everything became clear! Hell with JUnit, forget about Cactus, who cares about Mock Objects? God bless try-catch.\r
\r
My presentation is going to be just one page with the screenshot of this code and a large, stupid smile to go with it.\r
\r
Seriously, you can not write more error-proof code, can you? ;)\r
\r
:)