X

Geertjan's Blog

  • May 26, 2006

Zen and the Art of Code Completion

Geertjan Wielenga
Product Manager
There's a lot you can learn from code completion. With this iText API that I've been looking at, I didn't need any documentation to discover the basic functionality that the API makes available (especially since, like most semi-literate computer users, I know what kind of features PDF writers make available and was therefore able to map the methods I saw to the functionality I knew about already):

Looking at the above two screenshots, and the methods that appear to be provided by this API, I was able to implement some very basic PDF writer support in the Options window:

Note that the above functionality works! It's not just a screenshot... In fact, if you click here, you can have a look at the NetBeans API's CookieAction class that pulls together all the bits and pieces of my module and enables me to create PDF files. The link takes you to a document that uses "landscape" orientation as well as "thumbnails", as in the screenshot above. (And I didn't do any post-processing. The document appeared exactly as you see it here.)

It would be great if I could create a bookmark per method, as someone suggested in comments at the end of one of my recent blog entries; but I suspect that that would mean that each method would need to be added to the document separately (instead of the whole selection, as is currently the case). Otherwise, how can iText know where one method ends and the next begins? Also, it doesn't seem very likely that it is possible for the syntax highlighting to be maintained in the generated PDF file.

Apart from the above two issues, I think the iText API provides a great learning opportunity, both in relation to Swing components (it took me a while to get the jRadioButtons to work correctly) and in terms of the NetBeans APIs (as well as, of course, in terms of the iText API itself). And code completion is wonderful in supporting you in learning about all of these things.

Join the discussion

Comments ( 1 )
  • Alex Lam Friday, May 26, 2006

    That's is how I learn most APIs as well, with or without detailed documentations in javadocs.

    [rant]Wish life is just choosing the appropriate API calls and reading javadocs...[/rant]

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.