What have I learned from migrating and refactoring code?

Vu Tien Cuong
7LAB
Published in
2 min readMay 27, 2022
Photo by Mohammad Rahmani on Unsplash

The context

Our system had multiple components written in several languages (Ruby, Go and Java) many of which we have trouble maintaining due to the lack of developers proficient in Go and Ruby. This coupled with the fact that while mostly functional, these components were severely outdated has led to the decision of migrating them to Java.

The importance of documentation and unit testing

When I first started working on this project, it was an absolute nightmare figuring out what needed to be done. Most of the code was written long ago at a time when requirements were changing rapidly, this resulted in outdated or missing documentation and unit testing. We ended up spending a massive amount of time in meetings trying to determine what is running correctly and what is not. This could have been easily avoided with proper documentation and unit testing.

Though documentation and unit testing is tedious and time consuming, it will save you a lot of time down the line so please try your best to keep those up to date.

Refactoring: Stability vs change

A question I constantly ask myself through the course of this project, is whether a confusing, badly written part of the code should be refactored.

Leaving the code as it is ensures the system continues to run normally, however poorly written code tends to affect performance, as well as being difficult to update or maintain. Refactoring could solve these problems but this often means an increase in time and workload. Communication in these situations is crucial, whatever decision you end up making, be sure that everyone is aware.

When and where to refactor or not is a difficult division to make. Therefore, explaining to your team why changes should be made is important. Make sure everyone is on the same page in order to make the best decision.

Learn a lot from reading Go and Ruby code

I was only familiar with Java when I started this project, so I was a little worried about working with Go and Ruby. Reading code from different languages allowed me to see new ways to approach the same problems.

Learning Go and Ruby was difficult and though I am nowhere near mastering neither of them, this has given me a chance to broaden my horizons as a developer.

Programming languages are tools for problem-solving and I glad I added two more to my toolbox

Conclusion

There is still a lot to learn in the world of programming but by sharing what I have learned, I hope to motivate myself to keep on improving as a developer. If any of this end up helping someone else with their problem then all the better.

--

--