So here it is:
Click for larger view... |
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