Tuesday, January 31, 2006

Code Quality

Michael Feathers : "The Bar is Higher Now"

and a more radical (language-style) one
Dave Astels: "Why Your Code Sucks"

both are very good.

Saturday, January 21, 2006

Checked Exceptions

Here is more hand-cuffing from Sun: Checked Exceptions (read here and here).

Why there are checked and unchecked exceptions?
Aren't both equally dangereous for your program?
And why checked? Why do people have wrap and to push an exception up to the point where checking makes a sin?
Is my program more safe if I use Checked Exceptions? Hmmm. I would understand it from a declarative point of view: I tell you, my API Customer, that this function will/ throw an exception,
but how do you handle it is your bussiness, and not the compilers. But eventually you and I will have to write TestCases for your code, and these Specify/Document my API and your code.

Haven't we learn anything from Smalltalk?

Dynamic vs. Strong Type Systems

Dave Hoover, the "Red Squirrel" makes/collects some good observations here
(Dynamic languages + TDD) == (power + safety) == confidence.
Yes. Free your self from "hand-cuff" programming, and do your TDD.

Strong testing is fabulous, no doubt about it: the problem is that most developers don't have the discipline to write and update their test suites. The consequence is that, in the real world, there actually are benefits to static typing in complex projects. One way of thinking about static typing is as "just another test suite", except that it's a test suite developers are less likely be lazy about or subvert.


No, No, No. The compiler is no tester. I am still surprised to see how many developers measure their progress in lines of code compiled, and not in feature tested.(see Running Tested Features) Having the code compiled does not mean, that a function will not through an exception on a null pointer, or when an empty string comes as parameter. So where is the "TestSuite"? That the function accepts a string as parameter, and every caller supplies a string? This is very "thin" for a TestSuite.

The "safe language" argument appeals to fear, while the "flexible language" argument appeals to a sense of opportunity and adventure. Both are powerful motivations, so for a long time this argument has been a stalemate. Happily, that period is coming to an end. Two new factors have come into play: automated testing and transparency. Over the next five years they will turn the balance totally in the favor of more flexible languages.

:D I remember a quote about XP that the most methodologies are based on "fear", but XP is a methology is based on "fun". And there is no safe language, there are only tested programs. If somebody asks at the end of the day what have you done, you say: "I have 30 specifications, running, and I tested my code against them". If these specifications are good or wrong, that is another story, but at least you can say I can prove that for this 30 cases, my cod works.