I have been using the java Restlet api for network topology stuff and it is quite nice. Seldom do you come across cleanly designed APIs these days it seems. It avoids a lot of the common pit falls java apis seem to enjoy:
- Factory diarrhea == teh sux
- Everyone who has used java has probably experienced this. If you are writing api realize that most people don't give a crap about a configurable factory. Give people concrete instances of things that default to a particular implementation. Configurablity is good but I should not need to enter a deep philosophical debate with my compiler just to determine how it should parse XML.
- Fixed verbosity
- Most libraries have a fixed way something must be done. More than likely the level of verbosity required to do it inappropriate for what the user is doing. Design your classes so they can function with out extra functions calls and other pointless boiler plate code if you can. When the user needs more control they can specify it when needed. People can learn your library faster and programming with it will be much more pleasurable.
- Documentation
- People seem to have strange ideas about what appropriate levels of documentation is. Hint: you need more than just javadocs/doxygen output. Your software should be the sum of its parts. Documenting the individual pieces in isolation with out providing more detail makes learning how to use your code orders of magnitude more difficult.
- Use standard abstractions
- If the language provides a standard library with things like iterators and structures use them! If programs are essentially language recognition and translation (which they are) then using common concepts is essential. If you don't do this you are failing at communicating with the people reading your code and also doing a poor job communicating with the machine which you are instructing.