News for hackers. Stuff that matters.
Re:How to write untestable code by txxxxd on Thursday November 05, 2009 @06:15PM (#925027)
It's too bad Java/C++ were designed after unit testing became commonplace. Some of the advice here will actually improve your production code but a lot of this is just a case of the programmer having to work around the language.

For example, the advice to not "instantiate objects using new in the middle of methods" wouldn't be a big deal if if your test code could easily instruct the compiler to replace the concrete object with a mock when the test is run.

Re:How to write untestable code by ori_b on Thursday November 05, 2009 @10:38PM (#925380)
Nothing prevents that being implemented in existing compilers. In fact, you can already do that in Java with class paths.