Modularity is Hard

More work on Disk Clock, none of it externally visible. Nonetheless, it was nice to work on something I really enjoy, and I found myself ruing the necessary errands and cooking Sunday. Much of Saturday was a weapons seminar; I came in to teach staff, but only sword students came, and I ended up learning some ken-jujitsu instead.

Untangling Disks

I did a little work directly on ties keeping the disks in place. A couple of them used loops to assign common properties after the fact. In one case a disk directly referenced the properties of another, requiring data to be extracted for common use and functionality to be made independent of the disk class.

Disks By Any Other Name

The disks and various functions that operate on them had been declared in a big closure that created DISKS. I refactored all of the functions out, creating a new `disks` collection for those that in fact dealt directly with the disk collection. The new collection is built up by registration, rather than an omniscient literal array.

There are actually two collections – the master set of disks and the live disks, derived from the masters by prototypal inheritance. This is looking towards a still-distant time when it might be possible to have multiple clocks on a page.

Not-so-ready: Set; wait

The collection of disk sets also needed some indirection. The sets are now specified by name rather than reference. Like the rest, sets have been moved but it is still a somewhat thinly spread piece of functionality. Much of my work lately has been aimed at extracting the feature, since it doesn’t make much sense to remove disks if there are still references to them.

One feature was a custom setting handler to reconfigure the disks when the set was changed. I found that this was heavily duplicated with the basic setting-changed event, and managed to implement it in the standard implmentPreferences function, which removed one bit of redundancy. Some time later that monolithic function will have to get broken up so each setting carries it’s code with it.

The next challenge was allowing the sets feature to reconfigure disks without being a core piece of the main application. I defined a small and still limited event system to handle indirect registration and firing of events. This allows the sets feature to activate the appropriate disks without requiring a direct reference from the main code.

Posted Sunday, October 25th, 2009 under Devlog.

Comments are closed.