Saturday, March 08, 2008

Cobra seems to be like Python with optional compile-time type-checking and other quirks removed.

It also has contracts, which ensure certain conditions when calling a function. However, wearing my new Erlangish hat, I wonder what contracts buy you over pattern-matching arguments?

Unit testing built in to functions is interesting. Not sure what I think of that .... yes, it's useful and convenient. But a) it may clutter up clean code (I tend to let a certain amount of messiness leak into my unit-tests, that I don't let into my code); b) it's not so easy to see how it can be used for test-driven development - how can I write my test before my class? And, worst of all, c) I tend to use unit-tests when refactoring and moving functionality from one class to another.

It's very simple to change a :


x = MyClass()
self.assertEquals(x.f(4),10)


into


x = MyClass2()
self.assertEquals(x.f(4),10)


and have my unit-tests already defining the new target I'm aiming for.

But if the test is is actually *part* of MyClass, then that's going to require more premeditated moving stuff around during my experimental refactoring.

No comments: