Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is one place where Unit Tests help nicely. If the group were using Test First, then the zealots would've had to read and revise tests before they rewrote code. They would've been able to read the test code and would've known about the business logic requirements. If they didn't do that, then failing tests would've clued them in.


If the function had a descriptive name then its purpose would be even clearer, and the calling code would be more readable too.

Nothing against unit tests, but I don't think they should serve as comments (which is more or less what you suggest).


Actually, I think it's important not to think of tests necessarily as "comments," but rather as "specs." This is pretty much the thesis of Behaviour Driven Development.

If your tests define what your program _should_ do, then your tests can become (a) more understandable and (b) more valuable to new folks familiarizing themselves with your code.

It's a subtle but important (IMHO) distinction.


Nope. Unit Tests are specs that automatically verify themselves.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: