I don't usually have much trouble figuring out appropriate designs so that my code is flexible and easily extended. But now I'm writing a desktop app in java and realizing that though I've written plenty of flexible code, I've never actually experienced the process of extending it after it has already been installed on somebody's machine somewhere out there on the internet. Say I have a class called Widget, and I've come up with an improved version, which is a subclass of widget (ExtendedWidget). I want the desktop app to query the server, realize ExtendedWidget is available and should replace Widget, download and install ExtendedWidget, and then reboot using the extended class rather than the original one.
Haven't had time to think about this extensively, but here's what comes to mind initially. The app is deployed in a jar file, but has files with the saved work of the user. I could put a directory within that structure, say "updates" which is a neighbor to the directory where the user's work is stored. After downloading the new class file I put it into the "updates" folder, then reboot the app. The app has its class loader fixed to where it first loads classes from the "updates" directory, loading classes from the jar file only if they are not first found in the "updates" directory.
So... what do y'all think? Is this a good idea? Is there some kind of design pattern out there somewhere that addresses this issue in a better way?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus