Before I start to write on this topic, I want to say a word on the MOOCs that are being widely offered these days. I got hooked up with edX’s Introduction to Computer Science and Programming course. Though I had my initial presumptions about its naivety, its a pretty decent course. Even if one has a degree in Computer Science, s/he can still take that course and learn something that s/he hasn’t learned so far. Right now, I am having a similar experience. I am learning new things, especially the Python programming language. I am happy that I did not let my presumptions affect my judgement. The way the course is organized, the way the problems are laid out, the way things are introduced, rather silently, in problems are just fascinating to me.
So much for the hypothesis. Coming to the point, one of the things introduced, silently, in the assignments was some kind of TDD – Test Driven Development. The basic idea is to test as we code. For example, if an assignment problem entails us writing 5 functions, then there will be a test module that imports these functions and calls them and tests them independently, given the functions’ signatures. So, when we run the test script for the first time, all tests fail. As we implement the functions, the tests will pass one by one. This kind of development is generally called as TDD. It builds confidence into the code (and into us). The organization (or realization) of TDD w.r.t the python scripts/programs is rather impressive to me.
One more lesson that was sent home, again rather silently, is the usage of comments. Whenever a variable is initialized, there is a comment above it that says what type the variable belongs to and what its purpose is. And then, there is another usage of comments. That reminds me of my university professor who used to say that we should first write comments and then fill code in between. That’s exactly what is done here. Then, my professor’s suggestion looked rather heavy to me. But, he, sure as hell, had wisdom!