lgarron/twisty.js — pull request #5 by jfly (2011-10-10 11:14:37+00:00)
Title: Multiple twisties!

The most significant change here is a03068c. See ncubes.html for a demo.

git show a03068c:

commit a03068c870a438e2821548e4bb16be32098fa0a3
Author: Jeremy Fleischman
Date: Fri Oct 7 13:34:28 2011 -0700

twisty.js has been lightly classified. It is now possible to create multiple isolated twisty instances. See ncubes.html for an example of this.

Right now, twisty instances are isolated within a TwistyScene. I'm not very happy with this name, however. I documented my thoughts on this inside of the TwistyScene.createTwisty method, but I've copied the comment here to ensure that it doesn't get lost in this 1k+ line commit.

// TODO - discuss the class heirarchy with Lucas
// Does it make sense for a TwistyScene to have an addMoves method?
// Scene implies (potentially) multiple twisties.
// Perhaps rename TwistyScene -> TwistyContainer?
// Alertatively, TwistyScene could become a Twisty base class,
// and twisty instances inherit useful stuff like addMoves.
//
// I personally prefer the first method for a couple of reasons:
// 1. Classical inheritance in javascript is funky. This isn't a good
// reson to not do it, just personal preference.
// 2. Creating a new twisty doesn't force recreation of the TwistyScene.
// Maybe this isn't an important case to optimize for, but to me
// it's evidence that having a persistent TwistyScene is the right
// way to go.