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

Tests! Tests! Tests!

If the author had written thorough unit tests first, they could have then engaged in fearless refactoring, they would have been orders of magnitude less likely to have broken any functionality, and what's more, nobody else would have cared about or minded the change in code.

Write whatever dirty abomination you want. Then unit test the crap out of it. Then refactor it into the pristine shining epitome of every pattern fanboy. As long as it works, before and after, nobody will berate you for it.



> As long as it works, before and after, nobody will berate you for it.

This is not the reality in most places. People care about aesthetics, and about practical issues like how maintainable the code is, even if the code is thoroughly tested.


Still it's quite rude when some people spend a lot of time on some part of the codebase only to find someone rewrite it without discussing it first.

Also the point here is about cognitive cost of working on the refactored code, not broken functionalities.


Unless I'm misreading something the author does not mention breaking anything.




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

Search: