Test Driven Development
Red / Green / Refactor / Zombie Pets
We started test driven development today using Mocha, a test framework that runs on node.js, pairing with it the Chai assertion library. (I know, that sentence gave me a craving as well.) I guess you could say Mocha and Chai are about as sweet as they sound. Just like a hefty dose of caffeine can make your day run smoother, so can Mocha and Chai.
What is Test Driven Development?
Basically, it ensures that your code does what you think it does. I find it highly intuitive and efficient. First, you figure out what the code needs to do, write a test for it, then compose the code that will make it happen. Although the tests can sometimes be twice as long as the code, the verbose nature of it helps you think out in plain english what you intend to do.
Just read it like you would any sentence. (expect that Baxter is a zombie)
expect(baxter.isZombie).to.be.true;
This leads to a more direct coding process, (i.e. less staring at the blinking cursor wondering where to begin) because that blank screen can be quite intimidating.
Zombie Factory
With great power, comes great responsibility.
We used our constructors for bad. Instead of just stamping out cute little pets that we had to feed, walk and care for— things took a dire turn for the worse as a underground fighting ring took hold(in what @chyldmedford called “scope creep”. Our project quickly turned into a group of cage-fighting pets who turn into zombies if they lose. Don’t worry, we aren’t monsters, if they were strong enough fighters they could be resurrected… for a price. The code is pretty entertaining. Go ahead fork the project, the zombies won’t mind.
-Kayla