Learnings from the migration of 100k+ lines of Java code

Bárbara Almeida
Software Engineer II
Automatic Summary

Understanding and Undertaking Large Scale Code Migration: A Real-World Perspective

Greetings, coding enthusiasts! Today, I am excited to share with you some insights from my personal experience as a software engineer at Cadence Design Systems, Brazil. In this article, you'll learn about the intricacies of migrating large lines of code, its challenges and rewards, and how you can successfully execute it within your own teams.

Context and Justification

Why would one want to migrate hundreds of thousands of lines of Java? The answer is not short of reasons. Our initial codebase consisted of Java and C++. With most of the code in C++ and a small amount utilizing Java linked via the Java Native Interface (JNI). Our goal was to rid ourselves of Java and solely utilize C++. Having a dual-language codebase brought challenges that were gradually wearing on our developer efficiency.

  • It was problematic to set up - defining heap memory size in Java wasn't straightforward
  • Optimization was considerably difficult when dealing with the infrastructure in Java and C++
  • It made the code hard to maintain overall

Bearing these issues in mind, the objective to move towards a C++ only codebase was unmistakable. However, given our plethora of Java lines and the necessity to continue adding features and fixing bugs, the migration couldn't occur all at once. It was a slow and continuous process that took a few good years with multifaceted developer engagement.

Tracking Progress

One significant lesson learned concerns the vitality of tracking project progress. Anything left unmonitored can easily spiral out of control. Proactive tracking allows for a clear understanding of progression, and enables crucial adjustments relating to resources and intermediate goals.

Leveraging Different Levels of Experience

Another crucial aspect of such a large-scale project was the importance of leveraging the abilities of people from different experience levels. Senior developers played instrumental roles in building the infrastructure to allow progressive migration. Once the infrastructure was in place, a mix of junior and senior developers pushed forward with the migration. In essence, this variety in skill levels offered a great platform for juniors/beginners to ramp up their skills in coding and project progression.

Opportunities and Learnings

As the saying goes, "every cloud has a silver lining" - our migration project was no different. Throughout the process we were able to leverage opportunities to clean up our existing code, review and either continue, deprecate or adjust features as necessary. Such experiences imbibe the belief that there are always learning opportunities and benefits right from the start to end of a project. Amidst what may seem a daunting task, one should not overlook the underlying benefits.

Conclusion

In conclusion, this story serves to highlight the importance of code refactoring in software development. Larger coding projects such as ours may seem overwhelming and often without a clear end in sight, but I assure you, the end is there. The benefits, both direct like customer satisfaction, and indirect ones such as leaner and easier to maintain code are worth the blood, sweat, and code that you put in.

I hope our journey inspires you to embark on your own code improvement and refactoring initiatives in your teams. Remember, no obstacle is too large, and no code too complex! Connect with me on my LinkedIn to discuss more about this intriguing world of coding. Thank you!


Video Transcription

First a bit about me, my name is Bari. I'm a software engineer here from Brazil. I have been working at the Brazil's Office of Cadence Design Systems for almost five years now.And I've been working during this time in the development of Jasper EPPS, our RTL form a verification tool. I've also been engaged in initiatives for improved code quality and to empower women in tech and outside of work. I'm also passionate about creating art with code and about cats because to not to love cats. OK. So first a bit of context about why did we want to migrate lines of Java in the first place? We had a big code base with code in Java and C++ specifically with most of the code in C++ and some code in Java connected with Java native interface. And our goal that we achieved was to get rid of Java and JNR nine and have only C++ we wanted to do it because having both languages made something hard, something harder for us. And some of the examples of when it makes things harder, are harder to set up our tool in Java, we need to set the hip memory size and defining this amount was not always straightforward.

It would also be hard to optimize the code then needing to deal with the infrastructure in Java and C++ and the connection between that would prevent us to do some rich factories and some performance improvements. And it also made the code harder to maintain overall it. So we needed developers to be able to program in both Java and C plus. We also needed our tools such as indexers, linters, and sanitizers. We would either have them have to maintain them for both languages or not have all of the code covered. So it was clear that it was preferable to have the code in C++ only, but we still have hundreds of thousands of Java lines and we couldn't migrate then all at once, we cannot stop adding features and fixing bugs to do this code reflectors. So it was a long journey, it takes time, this took us a few years with lots of developers being engaged in that but slowly but continuously, we did reach it our goal and that's what I want to talk about. OK. So one first thing I want to mention in terms of learning through this project is the importance of tracking the progress. Anything that you are not monitoring can easily get out of control. And we have caught one example of that at the beginning of the project. Actually, some years before this project, there was already another initiative to migrate lines of code that had a significant progress but left one specific component in Java. And over time, the two have progressed features were added and the amount of linings have grow again.

And at the beginning of this specific project, when we created a tracker to understand our progress and look into the past as well, we were surprised to see that we were almost at the same amount of gel lines before doing any migration and obviously tracking was also really important during our project to understand our progress um in which space we could move so we could adjust the amount of resources or our intermediate goals.

Another thing I want to mention is that this type of project is a good opportunity to leverage the abilities from people from different level of experience. Since we needed time to do the migration for a lot of time, we needed the component to work with part of the code in C++ and part of the code in Java. So we could do the migration progressively and we needed senior developers to build this infrastructure to allow the migration. Once the infrastructure was done, we could progress with the migration, which is easy. So we did have um people from all different levels of experience, experience during the migration.

But we realized that it was really interesting for beginners because they had the opportunity to talk and have the help of the senior people on how to migrate and also doing code reveals and that could really improve the the ramp up of new hires because they were able to see the code and understand the structure of our code through the migration.

And another thing I want to mention in terms of learning is that there are also opportunities during the process. The the reaching the final goal was a really important mark for us, but we did have benefits during the whole process. And it was especially a good opportunity to clean up our code. We were able to find points where we could improve the, we can improve the code in the future, also weird things and possible bugs. But also we had the opportunity to review the features. We were migrating and understand if they were still being used if they were still needed. And for some features, we decided that we could deprecate them instead of migrating. So it was a further place to clean up the cold. OK. So to conclude, I want to highlight the importance of code refactoring of initiatives such as this in our specific cases, there were also ben direct benefits for the customers. But I often for code refactoring, that's not the case, but there is always the indirect benefit for customers when we make the code easier to maintain. So we can have less bugs and have faster response times. And another thing that I think it's important to mention is that this project is lot of time, they look really big and it's hard to see the end and it can be demotivating. But I hope our experience can show that it's possible to finish.

It's possible to reach the end. But even when we are steering the middle, even when we're still progressing weak, you can still uh have lots of benefits and lots of learning and in other opportunities in the middle of the project as well. Ok. Um That's it. Um I hope our, our experience can inspire you to work in on the opportunities of code develop of code improvement, whatever makes sense in your teams and thank you so much, you can reach me on my Leine.