Agile Ajax

GWT Conference: Best Practices for Building Libraries

Joel and Kelly stepped us through 10 principles for writing good GWT libraries.

  1. Design for real use cases
  2. Create independently useful pieces (don't try to prematurely wire everything together)
  3. Don't use a Widget when all you need is HTML. (Widgets let you handle events. If you don't need to handle events, or can handle it in an upstream (parent) Widget, don't use a Widget)
  4. Design with compiler optimizations in mind (ditch static initializers if you don't need them, stay tuned for more documentation about the compiler and its optimizations)
  5. Identify your invariants and make them immutable (example, instead of a LinearPanel whose direction you could change, they now have VerticalPanel and HorizontalPanel)
  6. Beware of implementation inheritance (No brainer. Work with interfaces. GoF is 80% about refactoring class inheritance.)
  7. Make it work in Mozilla, IE6/7, Safari and Opera (If it is a GWT library, it should work everywhere that GWT supports)
  8. Use the builder pattern (see RequestBuilder for an example)
  9. OO is a tool, not a goal. (Don't create objects just for the sake of creating objects, it sucks for GC)
  10. Read Effective Java

The discussion devolved into IE bashing (with occasional shots at Safari 2). One of the GWT engineers mentioned the possibility of performing object pooling at the compiler level, but that is somewhat off in the future.

"The cost of a bad decision in application code is just restricted to that application; in library code, the cost of a bad decision is multiplied by all the people who use the library." -- JW

"Design to real use cases, not to someone's fantasy." -- KN

"99.9% of all the use cases I have seen for adding widgets to trees involve adding images or check boxes." -- JW

"IE6 has perhaps the worst garbage collector ever written." -- JW

"Handing out mutable copies of your internal state is just a bug waiting to happen." -- JW


Technorati Tags: ,

Topics:

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com