Tuesday, September 30, 2008

Whiteboarding: A form of torture?

The whiteboard pattern is a pretty well-known "best practice" in the OSGi community. For this reason, I was somewhat surprised to hear from a co-worker (echoed by a couple folks at EclipseCon) that not everyone considers this pattern a blessing. Unfortunately, I have never seen this argument laid out in writing before, so I thought I would give it a shot in this blog entry--apologies if I do it no justice.

The whiteboard pattern is basically a modification on the standard listener pattern in which the content publisher looks up its consumers in the service registry instead of the consumers hooking themselves into the publisher. For a deeper understanding, there is lots of good info available including this whitepaper. This pattern purportedly works much better (fewer lines of code, less prone to error, etc.) in the dynamic world of OSGi services...so why wouldn't everyone love that?

The answer (and I suspect this is an eye-of-the-beholder thing) is simplicity. Although the code presented in the whitepaper makes it pretty clear that using the basic framework to implement the traditional listener pattern can be quite burdensome, I am not convinced it must be this way. With the improvements in service frameworks like Declarative Services, it is becoming easier and cheaper to develop a system based around service interactions. So if the programming complexity becomes similar, in what way does the whiteboard pattern introduce additional complexity?

I can say from first-hand experience that the loosely-coupled nature of OSGi services can be a dual edged sword...powerful yes, but also difficult to follow. When you step into a large project with lots of service dependencies, it can be hard to untangle the interactions and see how the pieces fit together. This effort is made even more difficult in code which uses the whiteboard pattern. The registry becomes entangled with a bunch of listener objects, which have no clear indication of who should call them or what service they are providing to the system. Additionally, the developer is expected to know that they can hook into a particular producer by implementing some standard interface and publishing it to the registry. This type of hidden interaction model can be very tricky to find and needs to be well documented to be effective...or else it can start to feel a bit too 'magical'.

The beauty of the service registry is that it gives us a single place for safe, dynamic, loosely-coupled bundle interaction. So what we would really like to see in the registry is the "service" a particular bundle is offering to the other bundles in the system. On the one hand we have a pool of content consumers offering only a "listen" service, while on the other we have a content publisher who allows you to register your interest with its content. Now which of these bundles do you think more accurately fits the average developer's notion of "service"? I wonder why we don't see this type of "whiteboard" pattern in distributed SOA systems...

Friday, September 5, 2008

Keyboard Shortcuts - Others

In my previous post I covered my favorite Eclipse shortcuts fairly extensively. Here are some of my favorites in other programs:

Browsers/Apps

Most folks know that Firefox, IE7, Chrome and some other tabbed interfaces provide the following shortcuts for working with tabs:
  • Ctrl + T => New Tab
  • Ctrl + Tab => Next Tab
  • Ctrl + W => Close Tab
You can also hold the Ctrl key when following a link to open it in a new tab in the background. Similarly, you can hold the Shift key instead to have it open in a new window altogether.

Perhaps a bit less known is
  • Alt + D => Goto the Address Bar
While there are similar shortcuts to do the same thing, this one will work across Firefox, Chrome, Internet Explorer, Windows Explorer (the Windows File Manager) and most other apps I've used with a similar layout.

I have begun to use this Alt + D shortcut in combination with the Quick Search feature in Firefox. This is a feature that allows you associate a keyword in the address bar with a particular type of search. Firefox comes preloaded with a number of useful ones, including "wp" for wikipedia (though my Linux version of Firefox 3 seems to be missing these for some reason). To try this out, simply navigate to the address bar and type "wp firefox". This should pull up a page with the results of the wikipedia search. You can even set your own Quick Searches (much like setting a bookmark). For more info on this nice little feature, check out http://lifehacker.com/software/geek-to-live/geek-to-live-fifteen-firefox-quick-searches-129658.php

Finally, there are the page search shortcuts (at least in Firefox).
  • / => Find As You Type Text
  • ' => Find As You Type Link
I still tend to use the Find shortcut Ctrl + F for text searches instead of / because you can more easily toggle through multiple hits. However, the ', search_string, Enter sequence is a very useful one for quickly finding and following a link on the page.

Finally, some new-fangled, web 2.0, RIA, Ajax-enabled, Software-as-a-Service webpages provide their own shortcuts. The only ones I know of and use are the Google shortcuts (especially for Gmail and Reader). In particular, I find the use of j/k and n/p to navigate lists/items quite useful. For a useful reference list, be sure to type '?' while in one of these services.

Operating Systems

Operating systems usually provide some useful shortcuts for managing the desktop and the running applications.
  • Alt + Tab => Switch between applications
If you continue to hold the Alt key (and have multiple apps running), pressing Tab multiple times will cycle you through a list of the running applications. Interestingly, there is a lesser known Alt + Esc shortcut which can be used to switch between applications in-order (queue) as apposed to the last used (stack).

On my work computers I use Windows XP and have gotten familiar with a number of the special windows shortcuts (many involving that silly little "windows" key between Ctrl and Alt on the keyboard). Of these shortcuts, perhaps my favorite is:
  • Winkey + D => Show Desktop (Toggle)
However, for some reason, this shortcut doesn't work on my T60p Thinkpad! For more shortcut-related info on the Windows Key, be sure to check out http://www.codinghorror.com/blog/archives/000378.html

Well that is enough for now. I will have to write new posts or update these ones as I find particularly useful shortcuts which I have missed.