When starting a new project, dealing with legacy code can be a daunting task. Patience is a virtue; if you can, take your time to understand the code and document it well. Don't rush the process, as this can lead to mistakes and introduce new problems into the codebase.
But what if you're on a tight schedule. How do you handle it? What strategies have you found to be most effective?
Share your experiences and insights on legacy code management with the Newbie community. Let's learn together!
Latest comments (30)
Good thread...yes i have worked on many legacy code...different languages, intricate components architecture and existing issues and new features to update....sometimes no documents will be available, no comments will be there...the people who had worked on that will not be there....So i follow the procedure.
1) If i dont have documentation, then first go with the functionality test and note down how many functions are supported by the software...excel or any spreadsheets...
2) For each function, i will verify as a tester and then also do unit test to check what works and what does not work...elaborate process but i extend my work timelines from 8hrs to sometimes 16hrs or more...but this effort will help later.
3) once functions are clear, then as a developer do run and perform code workflow and check all the entry, exit points...sometimes it is events/multiple threads/multiple processes involved...those times in your code type logs for all the major entry, functional steps and exits to cross verify your understanding.
4) All these please take a separate code base/directory , as the main baselined code in source control should not be affected by any way...so do all these verifications in s separate code base.
5) Main split your working time based on priority of everyday task and the learning and documentation...surely many night-outs i have done just to learn and document...but it will help us dearly when clients ask for new features to update/do complete migration...you will feel control of your own product.
6) Mainly understand the issues/bugs in the legacy code...perform thorough analysis before fixing the same...as it will break existing functionalities and we will go in a loop of rework.
hope it coincides with others worked on legacy code and helps
Thanks You!
In this article, we tell you how to handle legacy code in order to optimize it and make it more understandable, compact, and secure. You can decide not to touch what is already written.
Legacy codebases can be a double-edged sword. While they offer tried-and-tested functionality, they also often harbor outdated practices or design choices that don’t align with modern requirements or standards.
If you're on a tight schedule it's important to acknowledge that you're in a trade-off situation with the stakeholder. Occasionally, they may strategically choose to take on technical debt (the quick and dirty approach) to free up resources for more immediate concerns or higher priority features.
The real trouble creeps in when the stakeholder doesn't realize they've taken on debt.
It’s crucial that the decision to take on debt is conscious, deliberate, and aligned with the project’s long-term goals. Even as a #codenewbie, communication about the issue is huge! Awareness of the sources of technical debt equips teams and stakeholders to manage it effectively.
The phrase, "Okay..., and...," has worked wonders for me.
"We need this horse to be black and white with stripes."
"Hm, sounds like you'd like a zebra."
"Yea, make it a zebra."
"Zebras are pretty rare in these parts. It's going to take some time to do it right."
"That's not going to work for us. We need it by the end of the day."
"Okay... we'll paint the horse for the picture, and... we'll get going on the zebra. It's going to take some time for the zebra to come online, but you'll make your deadline and you'll be able to market your zoo."
... etc.
Help the stakeholder get where they want to go while also satisfying the urgency.
Handling legacy code when starting a new project can be a challenging task. Here are some tips on how to approach this situation:
Understand the existing code: Take the time to review and understand the legacy code. This includes understanding its structure, dependencies, and how it works. This will help you to identify potential issues and dependencies with the new project.
Identify areas for improvement: Identify areas where the legacy code can be improved or updated. This may include refactoring, cleaning up code, and updating outdated libraries or frameworks.
Test the code: Test the legacy code thoroughly to identify any issues or bugs. This will help you to identify potential issues and dependencies with the new project.
Plan for integration: Plan how the legacy code will integrate with the new project. This may include identifying APIs or interfaces that need to be developed.
Incremental updates: Rather than trying to update the legacy code all at once, take an incremental approach. This will help to minimize risk and make it easier to manage the project.
Document the code: Make sure to document the legacy code and any changes that are made. This will help to ensure that the code is easy to understand and maintain in the future.
Involve the team: Involve the team in the process of handling the legacy code. This will help to ensure that everyone is on the same page and can work together to address any issues or challenges that arise.
By following these tips, you can effectively handle legacy code when starting a new project and ensure that the project is successful.
dd
Found the Laravel dev :p
i don´t get the title: what has "legacy code" to do with "a new project" ? how do you start a "new project" with "legacy code" ? ;-) that sounds totally paradox to me, sorry.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.