I added one new class last week and it changed my view of everything else. This one class, after being created, seemed to ask to be included in a dozen other classes: Its presence instantly suggested a handful of different ways to make those other classes cleaner, more streamlined, with less code and more tightly defined responsibilities.
Do other people have this experience very often? It seems to me that the code I had before had a bunch of tensions that were waiting to be refactored out, but those tensions were spread thinly across a bunch of different classes, so thinly that the quick solution to such wasn't obvious. The class itself (simply a Query object in an O-R mapping layer) isn't particularly clever. I just didn't see how strong the need for it was, before I actually created it. -- francis
I HaveThisPattern: doesn't anybody else dislike the odour of having multiple methods called addListener, removeListener, addActionListener, etc...? Instead of having the object handle the listeners itself, I tried merely exposing the multicaster as an Event oject. Wow... entire strings of delegated and duplicated methods disappeared. Instead of 'addWindowListener(listener)', I get 'whenWindowCloses().doThis(task)'. Although it is a bit more verbose, I find it much more self-documenting / less error-prone. Plus it forces one to use some form of GenericListener (a good thing; in my opinion, a listener's name should have more to do with what it does rather than the specific event with which it might be used). -- WilliamUnderwood
Named for the way large crystals rapidly form in a super-saturated solution once a small defect / seed crystal is introduced.
Brings to mind the sound of "thunk" I heard when performing such an experiment in High School Chemistry when I dropped a solid particle of Sodium-Thio- Sulfate in a super-saturated solution of it in a test-tube. It went from liquid to solid in the time it takes to say "thunk". It is my idea of what someone means when they say instantaneously. --DonaldNoyes