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

The last programmer was terrible...The code had unit tests, however, and that made it salvagable

This doesn't make sense, how could you trust his unit tests?



Because if they're falsely passing, hopefully between the code, and tests you could gleam more intent than just through the code itself


Exactly. Even poorly written tests are far better than none at all.


No.


By reading the unit tests and code comments, and comparing them against bits of the actual codebase, you can gain a better understanding of what the previous programmer was thinking and what he was trying to accomplish.


That's the most obvious benefit of having tests for me. Documentation can be outdated and even if it isn't it very rarely contains examples of use. Passing tests are for me exactly that. An up to date example of how the thing should be used and what can I expect from it.


In the old system a lot of things worked right.

For better or worse, this system had a number of data-centric objects; these objects passed many correct tests, but they failed to be deserializable from XML (because of the way collections were handled) as well as having other deficiencies.

The tests meant I could fix those deficiencies quickly and have faith that I fixed them correctly. Of course, I added new tests to test that the system did the things it had to do.




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

Search: