Modifying Objects At Runtime
Volume Number: 15
Issue Number: 3
Column Tag: PowerPlant Workshop
Modifying Objects at Runtime in PowerPlant
By John C. Daub, Austin, Texas USA
A look at PowerPlant's Attachments mechanism
Welcome!
One of the things that makes the Mac so great and so much fun to use is the ability to
customize your Mac just the way you like it. There are all sorts of cool functional
utilities like Monaco Tuner/ProFont and FinderPop, and many cosmetic enhancers like
the ubiquitous Kaleidoscope. Just how do these cool tools do the voodoo that they do so
well? Through the magic of trap patching! Patching traps is a neat way to change the
runtime behavior of an application and/or the OS itself without having to actually
change the application or OS. Think of it like subclassing to implement new
functionality for an object, but you didn't have to subclass to actually gain the new
functionality - something else came in at runtime and modified the object's behavior.
If that explanation only served to further confuse you, I apologize. However, by the end
of this article you will have a better understanding of the statement. You see,
PowerPlant has a mechanism akin to patching called Attachments. Attachments are a
way to modify the runtime behavior of PowerPlant objects, so in a sense it can be
viewed as patching. By using PowerPlant's Attachments mechanism you can extend,
limit, or otherwise change the behavior of a PowerPlant object at runtime, and all
through a mechanism that's simple yet very powerful; in fact the theory of the
Attachments mechanism will play a larger role throughout PowerPlant in future
versions of the framework.
By the way, if you're curious about trap patching, check out a book like Dave Mark's
Ultimate Mac Programming. Dave recruited Jorg Brown to write the chapter on trap
patching, so you'll definitely be in good hands.
Overview
PowerPlant's Attachment mechanism is comprised of two parts: the Attachment's host
and the Attachment itself.
Attachables