Brain Surgery While the Engine is Running
Sean Denigris explains how to do brain surgery on a bunch of existing Smalltalk objects when you make a code change:
Now comes the problem… I had objects floating around that already contained a non-empty OrderedCollection. I didn’t want to add otherwise-not-needed accessors. Luckily, because of Smalltalk’s awesome reflection capabilities, it was a breeze to reach into these objects and surgically change them.
You might wonder why that's useful, but consider this situation (which I've actually had):
- You make a code change for a running app server, such as the one you're reading this post on
- There are existing objects that have the old object shape, and need the new object shape
Just use the same sort of strategy Sean outlines above. I've done that a fair number of times over the years, both to the servers I maintained at Cincom while I was there, and to this one. It's a really handy thing to be able to do, because it's much, much better than the more standard tack of:
- Take server down
- Apply change
- Bring server back up
It works great, even in production.