Tuesday, October 18, 2011

Aha! Object-oriented programming!

Well, I didn't intend to rewrite any of the internals of Swift, only the GUI interface. However, now I see that I should have been using objects all along instead of nested dictionaries. The rewrite makes it vastly easier to use. Consider this snippet:
objects[currentselect[level]].frames[objects[currentselect[level]].frames[0].index(currentframe[level])+1][currentselect[level+1]]["yscale"]
This now becomes:
root.descendItem().currentFrame().currentselect.yscale
A bit more concise.

No comments:

Post a Comment