calband/calchart-viewer — pull request #35 by kmdurand (2014-08-09 05:23:55+00:00)
Title: Show, Sheet, Dot

Addresses #7
A few notes:
- I made a couple changes to the viewer file format: I changed all "facing" attributes of MovementCommand objects to be angle measurements instead of strings (e.g. "east" and "west"), and also made the arc movement differentiate between clockwise and counterclockwise movements by checking whether or not the angle of rotation is positive or negative.
- I added a class called the VersionManager, and used it to implement the ability to import shows from JSON files. The goal of the VersionManager is to help us easily maintain backwards compatibility when we change the file formats that we use. To use it, you register a function with it under a particular name and version. All functions with the same name are collected together, and you can request any version of that function;m but if there is a version 1.0.0, a version 2.0.0, and a version 4.0.0, and you request a version 3.0.0, you will get the 2.0.0 version (the highest version that is registered and that does not exceed the requested one). This is useful if you've split a big task into pieces, and only want to update one piece in the new version. As an example, suppose we make a change to the viewer file format, but the only thing that we change is the way in which the even step movements are represented. All we would need to do is register a newer version of the even step movement function; when loading older file formats, the VersionManager will fetch the older function, but for newer formats, it will fetch the newer one.
- I didn't implement fromJSON(...) as a static method for the Show class, since it caused a sort of circular-dependency in my requires. The fromJSON(...) function required the ViewerFileLoader (the VersionManager associated with loading viewer files), and the ViewerFileLoader required the Show class. So I decided to make a ShowFromJSON(...) function in its own file.
Anyway, let me know what you think!