Code change shouldn't be horrible

Was having a discussion with a developer and came across a topic about code change. Since he is very new in developing java stuff, now after getting thru the jungle for half a year. He looks back and realize many stupid implementation.

He then told me something he learnt from another developer, who has been writing code for some years that if code works, don't fix it.

I am quite surprised when he mention the rationale. It is the risk that the changes might break what works is inhibiting him from doing changes.

I can't help but "educating" this budding developer at the spot. With unit testing framework so widely available, there is no other reason but laziness or unrealistic timeline that no unit test is written.

Automated build and unit tests are so crucial that it should be conducted across the team as early as possible. Once it is in place, all code changes will need to endure through the bunch of test cases, before it is allowed to get into trunk. It is all the little test case that aggregates help us to build the confidence of code change.