Saturday, August 13, 2011

High-level DBFSpy UML diagram

Today I took a break from writing code, but decided that it would probably be a good idea to have at least a high-level UML diagram for DBFSpy's object-structure.

So here it is:

Click for larger view...
Though there is some detail available for a couple of the classes, I didn't want to try and arrange the entire thing with the available detail just yet... This at least shows the inheritance and implementation structure I'm anticipating, though.

A good part of the reason for my taking the time to draw this out was that I started working on the BaseFileSystemItemCache nominal abstract class, and it suddenly occurred to me that I wasn't sure how I was going to handle the potential circular dependencies between it and the IFilesystemItem nominal interface. The logic went something like this: When a filesystem item is deleted at the filesystem/database level, unless something is done to update (remove) that item from the cache, it will still be present. Fairly obvious. However, since Python won't allow circular class dependencies (each of these two objects needs to know about the other; one has to be defined and/or compiled before the other can use that definition), that poses a problem. Only one of the two classes can directly know that the item's been deleted, and without some way of connecting the two instances, I'd end up with either an invalid cache (which could be rebuilt, but that could be expensive), or an item that's still in memory, but that can't be accessed, wasting memory.

Observer pattern to the rescue, though, I think! Several basic structures have been documented on the web, so there's a handful of implementation-examples to choose from.

No comments:

Post a Comment