Tuesday, June 9, 2009

Zen of OSGi

Even though my favorite languages are Scala and Java (yes, Scala comes first ;-) ), I used to use the Python programming language quite a lot. Python has some very well thought out design elements and programming patterns. The Python community actively communicates these patterns and continues to promote their use. As a result of this, the Zen of Python (http://www.python.org/dev/peps/pep-0020/) was created to capture them in a jokey, but still useful way. There is even an easter egg in the Python interpreter (hint: "import this").

While beeing a platform technology in its core, the OSGi technology seems to use and promote certain patterns as well. The Whiteboard and Extender pattern are well-known examples for this. So why shouldn't we put these patterns in a more jokey and useful way?

Zen of OSGi
  1. Graphs are better than trees.
  2. Prefer services over objects.
  3. Import is better than required.
  4. Although required is better than classpath.
  5. Only export stuff you want to provide support for.
  6. Once you support something, support it forever.
  7. Import your exports.
  8. Minimise your dependencies.
  9. But do not omit imports you really use.
  10. Do not rely on start ordering.
  11. Listen to your customer, do not make them listen to you.
  12. Communicate your version policy.
  13. Be as permissive as possible but no more.
  14. Use the obvious OSGi way.
  15. Although that way may not be obvious at first unless you're Dutch.
  16. Expect the unexpected (especially when you are dealing with services).
You can even discover some interesting similarities between these two Zens.

Any important rules missing?

4 comments:

Erik van Oosten said...

Roman, myself being Dutch, but not from the OSGI incrowd, can you explain the Dutch reference in the final but last zen rule?

Roman Roelofsen said...

Tim Peters included the same rule in the Zen of Python since Guido van Rossum, the author of Python, is Dutch.

The idea of OSGi was started by Peter Kriens (Dutch as well), now the OSGi evangelist and actively involved in the standardization process.

I included this rule to pay tribute to the Zen of Python (for the idea) and to Peter for his great work and ambition.

Graham Jenson said...

Great post. A good simplification of the best practices of OSGi.

JS Bournival said...

I'm not dutch ... so I guess OSGi will flow into me more easily right? ;)