Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Visualizing Data: Self-Documenting Ant files

Interactive graphical views of your Ant build files give you more information faster, reduce errors, and provide intuitive methods to help you comprehend, modify, and test build targets.


advertisement
have always been fascinated by informational graphics. Mathematicians aside, most people find properly rendered information graphics easier to assimilate and quicker to understand than raw data, in whatever form that raw data may come in. This article applies concepts of data visualization to source code—not to what typically first comes to mind as source code (e.g. Java, C#, etc.) but rather the source code of an Ant build file.

Build files are notorious for being difficult to create, maintain, and understand, but you'll see a variety of techniques for visualizing or rendering an Ant file—some textual and some graphical—that will simplify the creation, maintenance, and comprehension of your build files.

The Art of Obfuscation
Most designers and developers endeavor to produce clearly written and maintainable code. But sometimes you want to deliberately produce incomprehensible code. Two reasons come to mind:

  • To help protect intellectual property rights where it is unavoidable that your code will be accessible.
  • To amuse and befuddle colleagues and associates, or take part in any of a number of annual contests just for fun.
The canonical example showing how graphics improve raw data comprehension is to show a table of numbers and then show a chart of those numbers, letting readers see how the chart shows trends at a glance that are much tougher to tease out from the raw numbers. But as software designers, perhaps you'd appreciate a more topical example; take a look at this C code:

_(__,___,____){___/__<=1?_(__,___+1,____):! (___%__)?_(__,___+1,0):___%__==___/ __&&!____?(printf("%d\t",___/__),_(__,___+1,0)):___%__>1 &&___%__<___/__?_(__,1+___,____+!(___/__%(___% __))):___<__*__?_(__,___+1, ____):0;}main(){_(100,0,0);}

I am sure you would agree that the purpose of the preceding code is not terribly self-evident! It was, in fact, deliberately obfuscated from the following code:

void primes(int cap) { int i, j, composite; for(i = 2; i < cap; i++) { composite = 0; for(j = 2; j < i; j++) composite += !(i % j); if(!composite) printf("%d\t", i); } } int main() { primes(100); }

Author's Note: Both preceding code fragments come from "Obfuscated code" at Wikipedia.

These two code samples show that different views of the same data may transmit very different amounts of information. (Final aside on that: if you want to learn how to write obfuscated code, a good starting point is the article "Writing highly obfuscated code in Perl.") This example is a bit extreme, of course, but it illustrates the point that well-written code—or more accurately, well-presented code—communicates more effectively than its counterpart.

That point holds true for other types of code as well, such as Ant files. In the tradition of classic programming tool nomenclature, "Ant" is a short acronym for Another Neat Tool.. Ant is an XML-based language for specifying how to compile complex software systems. Its predecessor make has been around since the early days of Unix, but was particularly unfriendly to edit (primarily because it was extremely finicky about the uses of spaces and tabs). Ant, on the other hand, uses standard XML syntax and, as you will soon see, has a variety of self-documentation tools, thanks to the extraordinary efforts of Ant aficionados.

Author's Note: I've assumed that you have at least a basic familiarity with Ant, so detailed explanation will be minimal. However, I'll provide some tips to help you avoid some not-terribly-obvious pitfalls.

Each section here describes a single visualization technique for Ant, beginning with a nutshell table summary. The summary should prove useful if you want to revisit this material later as a reference without having to read through the text in detail. The Rating column values are on a scale from one (worst) to five (best).

The small (206KB) downloadable code archive accompanying this article includes the collection of Ant build files along with the output for each technique discussed. For your convenience, a second, much larger (8.5MB) code archive includes both the Ant build files and all the external jar files you'll need.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap