Practical API Design

Posted by F Sun, 31 Aug 2008 22:14:00 GMT

I wrote about API design guidelines before, collecting links, resources, papers and hoping someone would write a book on the subject.

The wait is over! Jaroslav Toulash published a book on Practical API Design!

Take a look at the book’s accompanying website for more details.

I’m waiting for my copy.

Posted in ,  | no comments

Violating Java's privacy

Posted by F Tue, 20 Feb 2007 03:49:00 GMT

I found myself in the need to invoke a private method of a Java class that was out of my control. I really needed it.

So, I went ahead and violated the method’s privacy declaration via reflection. You can (under certain circumstances) invoke methods which are declared as private using the Reflection APIs (java.lang.reflect).

But before using reflection, I created two classes:

class A {
  public String method1() {
    return "Hello World!";
  }
}

class B {
  public static void main(String[] args) {
    A a = new A();
    System.out.println(a.method1());
  }
}

They compiled, and java B said “Hello World!” as expected.

Then, I made A’s method private and recompiled A. And I run java B again. Nothing changed. It just worked again.

That cannot be right. This would mean you can handcraft a class with the same name and methods as the original one but making everything public. Then you could use this class only at compilation time, allowing your code to call any method. (Or, one could modify the Java compiler to ignore access declarations altogether).

Read more...

Posted in ,  | no comments | no trackbacks

On API Design Guidelines

Posted by F Mon, 20 Nov 2006 03:31:00 GMT

Update: Good news! Jaroslav Toulash emailed me that he published a book on Practical API Design !!!


Looks like Brian McAllister may be preparing a talk on Designing Elegant APIs.

I've been very interested in good API design for a long time. But I could never find a single book on the subject. Many design and programming books provide good advice and guidelines that are essential for designing good APIs, but none of them tackles the matter directly.

I reviewed "Interface Oriented Programming" a few months back with disappointment. It may not be a bad book, but I felt it was quite basic and superficial. May be my expectations were too high, and too focused on API design.

Over time, I collected some links on the subject and shared some with Brian:

So, let's hope Brian gives his talk at a big conference, signs a contract with a big publisher and fills the void.

Posted in ,  | 1 comment | no trackbacks

AntDoclet 1.1

Posted by F Sat, 22 Jul 2006 20:43:39 GMT

I just released a new version of AntDoclet.

No major changes. Now the comments of inherited methods are properly extracted from the parent class comments.

Thanks to Daniel Lindner for this fix.

Posted in ,  | no comments | no trackbacks

GotAPI?

Posted by F Thu, 13 Apr 2006 02:16:00 GMT

Did you know about gotAPI.com?

It provides as-you-type lookups of reference documentation for HTML, CSS, Java, Perl and other programming languages and APIs.

Posted in ,  | no comments | no trackbacks

Older posts: 1 2