Welcome!

Java Authors: Maureen O'Gara, Bruce Armstrong, Liz McMillan, Walter H. Pinson, III, Yakov Werde

Related Topics: Java

Java: Article

Can the API Docs Be Improved?

Can the API Docs Be Improved?

The Java Dudes cartoon on the back page of JDJ has boosted my reputation as someone who likes the API documentation for the core Java language. It's easy to navigate, it's quick, and it answers some of those common Java-related questions. There are a couple of questions that are constantly on my mind. First, with such a rich resource of information, why do programmers (of all abilities) whom I have contact with fail to look at the API docs in the first place?

One theory is that there's a lack of detail about using some of the methods listed. Now, I know of sites like Java Almanac (www.javaalmanac.com) that provide good examples on how certain methods are used, but I do think these should be woven into the general API docs. Beginners would benefit from having a resource on their own system that would also provide general examples on how that class or method should be used without having to sift through the example code (can you remember when you last looked at it, I can't!).

There are small snippets of examples within the main class explanation; my goal would be to have a small code segment for the methods as well as a quick indication that I'm going in the right direction. The more that's added to the API as time goes on, the more that'll have to be documented. Obviously, there's a whole book-writing segment of the community who makes a living from bundling these examples into API reference books. Patrick Chan (and his team) has done an excellent service for the Java community with the Java Developer's Almanac and has obviously spent a lot of time looking at all the classes (hey, if you want music MIDI class information, it's in there). The same is true for David Flanagan, who wrote the Java Nutshell series for O'Reilly; he even wrote Java Examples in a Nutshell as the API reference was so large it was pushing examples out.

Apart from increasing the size of the download of the documentation, I don't see why Sun can't improve the example usage of methods with all the APIs regardless of whether it's J2SE, J2EE, or J2ME. The API docs should be the first point of reference for the programmer to help solve the problems. The more people I talk to, the more I'm reduced to pointing to the API docs (mainly on IRC). Now it's either down to plain laziness or the information that's presented is not up to the job. I agree that there are a number of Web sites with more information, but it becomes a major task to search these sites and get the required information. I'm finding that students in teaching establishments tend to ask questions without consulting these sites.

If anyone from Sun Microsystems is reading this, their blood pressure is probably rising on the simple issue of time management and what to include and what not to include, if any of my small wishes come true. What we could do is pick a couple of methods and write an easy example. These would then be checked and verified by Sun (because we don't want anything going into the API docs) and then it could be released. Now I do know that this means changing the JavaDoc statements within the actual class code, but most people install Java with src.zip installed, so I think it's worth thinking about.

I've looked at many open-source projects and documentation is the area where most things fall apart. We have to look at the whole picture regardless of how big the application is; even if it's a demo I want to know how it works. The SourceForge projects I'm involved in are pretty weak on documentation and I try to rally the troops to properly write about what they're doing and thinking within their code. It's like trying to land a plane and asking, "What does that dial over there mean?" "Well, Jase, it doesn't say anything, apart from the fact that it's being written at the moment." We can do better; we can do better.

More Stories By Jason Bell

Jason Bell is founder of Aerleasing, a B2B auction site for the airline industry. He has been involved in numerous business intelligence companies and start ups and is based in Northern Ireland. Jason can be contacted at jasonbell@sys-con.com.

Comments (3) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Gerry 03/05/03 11:09:00 AM EST

Sun really should pick up the ball and have a parallel API document showing usage. I've seen several aborted attempts at users creating an archive of examples cross-reference by the APIs they use (most recently at JavaLobby last year). The sticky issues are who decides what goes in, what stays out? Is the code example copyrighted, licenses, GNU, what?

I would suggest that JDJ is one of the few places that could pull together enough of it's own example code to create this cross-referenced API examples document. Otherwise maybe we go to SourceForge and set up a project and use Java Almanac as our inspiration and just hope that we can come up with enough good open-source code examples to fill it in.

Gunesh Apte 03/04/03 11:28:00 PM EST

Hi,

Yes, I agree with Jason. I was one of the first users of JDK1.0 when it was launched in mid-1996. Writing a simple Java Applet also used to be cumbersome at those times, mainly due to lack of proper, easy to access documentation of all the Classes, Methods. We used to spend lot of time in searching for useful code snippets on Internet, and then develop a meaningful descent code.

The books were the only source for Sample Programs, for AWT, Networking and other APIs in Java. We were used to the sample code snippets, sample API code in Microsoft Visual C++ 4.0, and from that to Java was a real pain for some people. People like me who have patience to explore, used to enjoy writing code in Java, and that also mostly in text editors like "vi", "notepad".

After so many years also, plugging the J2SE1.4 Docs to Java IDE is a task which needs to be done, especially if you are using light-weight Java IDE like Kawa. JBuilder/Visual Cafe provide more richer facilities as far as accessing API is concerned but still I suppose lack the Sample Examples part of it!

- Gunesh@mahindrabt.com

craig 03/04/03 08:23:00 PM EST

how do i find out what you are talking about? i am an experienced programmer, want to find out why the double-click doesn't work on my jbuilder 8 under linux, have spent four man-days trying to find an answer, and this little ray of hope fizzled, also.