Our good friend the Build Doctor helpfully reminds us that Ant is and should be declarative. The ant-contrib project consists (mostly) of non-declarative extensions, like
if. Would you put these in a regular expression (another common declarative language)? (If you answered “yes”, please stay far away from me.)
If you need non-declarative extensions you are probably writing a script without realising it, instead of declaring your dependencies and tasks to perform. So why not use one of the many nice scripting languages and call your script from Ant, or write your own Ant task? This and more inspired by the CITCON Paris session on better Ant builds.
We’re now nominating a code-quality theme each month, to help us focus on good practises and undo some of our code debt. Our first theme was Don’t Repeat Yourself or DRY. We found lots of examples in our code, both good and bad, on our Fame and Shame board devoted to the theme, including:
- two pieces of code that compute the same value – with different algorithms;
- two screen-layout files that are identical except for a few lines at the bottom; and
- some clever use of function composition to remove duplication and shorten a lengthy and confusing class.
We also had a number of 5-minute lightning talks on the topic throughout the month.
Developers came up with pictures and slogans for some demotivational posters on the theme that you may find amusing: