The Path Through Legacy: Delicate Balance Between Tolerance and Phobia

Rate this content
Bookmark
Slides

As a front-end teamlead, I was faced with the challenge of transitioning multiple legacy projects, which happened rapidly and was a painful process. One of the main issues I encountered was dealing with a legacy project that had no documentation. I had to figure out how to stabilize it, put it in order, and reduce the cost of its maintenance and development.

This talk has been presented at React Summit 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Legacy code is not just old code. It's code that cannot be easily extended or modified. While the age of the code can contribute to it being considered legacy, the primary factor is its usability and maintainability.

To prevent your code from becoming legacy, optimize it for change, make it easily modifiable, and write tests to ensure full coverage. Document your code well and keep things isolated to minimize the impact on the rest of the codebase.

Documentation is crucial because it helps future developers understand and modify the code. Well-organized and up-to-date documentation makes it easier to navigate and extend the codebase, thereby preventing it from becoming legacy.

Rewriting legacy code is justifiable when a particular section of the project has reached its limit, requires complicated hacks or workarounds, or if certain components are no longer in use and can be isolated.

Legacy code is characterized by its inability to be easily extended or modified. It often lacks proper documentation and tests, making it difficult to update and maintain.

Incremental changes help improve legacy code by gradually making updates and refactoring. This approach allows for continuous improvement without the need for a complete overhaul, making the codebase more manageable over time.

Tests are essential in managing legacy code as they help ensure that changes do not break existing functionality. Writing unit or behavior tests for each section of the codebase can gradually achieve full coverage and make the code easier to update.

A codebase should not depend on a single person because it ensures that multiple team members can understand, modify, and extend the code. This reduces the risk of bottlenecks and makes the codebase more resilient and maintainable.

A healthy codebase is one where any team member can make changes and new developers can quickly understand how to work with it. It should be well-documented, have tests, and be easily modifiable.

The ultimate goal for engineers working with legacy code is to solve problems through code while making incremental improvements to the codebase. The focus should be on creating code that is easily modifiable and maintainable, ensuring it remains useful over time.

Maxim Nam
Maxim Nam
8 min
06 Jun, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Legacy can refer to ancient architecture or old code, and it is important to acknowledge and address legacy issues. Legacy code can be disorganized and outdated, making it difficult to update and extend. The goal is to leave the code base in a better condition than before, prioritizing code that is easily modifiable by others.

1. Introduction to Legacy

Short description:

Today we will talk about the legacy. Legacy can be some ancient architecture or old code. Legacy games built upon previous iterations to create a unique gaming experience. Acknowledging the problem in time is essential for combating legacy. Rewrite may be justifiable in certain circumstances. Documentation is important but often neglected by developers.

Hi, my name is Max. Today we will talk about the legacy. First, a couple of words about our projects. In Teotihu, Kazakhstan, Altel Digital, we developed four main mobile apps, more than 10 web applications, and more than 150 microservices.

Let's talk about good old essential problems. What is legacy? It can be some ancient architecture, maybe board game cases. Everyone left their legacy path in this world. It works in both ways. Stickers on your board game map or your package cross-dependency in React project. Well, both legacy board games and legacy codes share the same commonality of passing the down something from the past. The nature of their legacy is entirely different. Legacy games built upon previous iterations to create a unique and personalized gaming experience.

So what is legacy code anyway? You might fall into the trap of thinking that it's just an old code. Yes, it can be old. But old code is not necessarily considered legacy just because it's old. With this approach, your own very code you wrote yesterday is legacy by now. Next or following characteristics might seem familiar to you. The answer that we write code which most likely ends up as legacy is outside of the actual coding process and implementation aspect. If you are making your own small project or startup, you are more likely to write fast and revisit later. Nowadays if you haven't taken this route as a small team or one-man army project, you most likely don't have a business. The key is acknowledging the problem in time to move the practical ways of combating the problem. Unfortunately, there is no such instrument in software development like MagiKwan or Sword of Thousand Truths to make everything we want perfectly. But just as weapons and mana bars are tools to success in gaming experience, standard commitment is essential for using technology effectively and responsibly.

As developers we find the idea of rewriting because it's easier. At least, that's what we think. It's easier to judge code written before us and think we have a better solution, often ignoring the business logic that old code serves and what edge cases it was trying to solve. While I tend to believe that rewrite is often not necessary, there may be certain circumstances where it is justifiable. For instance, if a particular section of a project has reached its limit and further expansion requires complicated hacks or workarounds or if certain components are no longer in use and can be isolated, starting anew may be the best course of action. Documentation is one of those things that all developers agree but few do. At least in a practical and efficient way.

2. Challenges of Legacy Code

Short description:

You can write an endless amount of disorganized, outdated mess which makes it incredibly hard to update. A piece of code might work but it's not useful if you can't extend it. Remember what I told you before. The code you write today is old code by tomorrow. Our task is to leave the code base in a bit better condition than it was found. Rather than following best practices, it is preferable to prioritize creating code that is easily modifiable by others.

You can write an endless amount of disorganized, outdated mess which makes it incredibly hard to update. It's far easier to write lots of mindless documentation. Some say code base can be documentation by itself but having small number of links and anchors in your repository can be a thing. It's pretty much an art in and of itself.

A piece of code might work but it's not useful if you can't extend it. Sure, it can work as expected and still generate profit for the company but one day it can break the entire business workflow. We can minimize the problem by keeping things isolated so it doesn't affect the rest of the code. This can be a permanent solution.

Usually when you write new stuff they will depend on some legacy system, depending on the size, the larger the size of the code base the more challenging it will be to fix it. So, optimizing your code for change and making it easier to delete ironically makes it easier to extend in time and you will not produce legacy code today. Remember what I told you before. The code you write today is old code by tomorrow. Is your intention to be the most clever or is it to help all other future developers that will probably come long after you are gone? Our task is to leave the code base in a bit better condition than it was found. Rather than following best practices, it is preferable to prioritize creating code that is easily modifiable by others. The goal here is to slowly make incremental changes on legacy system.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.
Remix Architecture Patterns
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Remix Architecture Patterns
Top Content
This Talk introduces the Remix architecture patterns for web applications, with over 50% of participants using Remix professionally. The migration from single page applications to Remix involves step-by-step refactoring and offers flexibility in deployment options. Scalability can be achieved by distributing the database layer and implementing application caching. The backend for frontend pattern simplifies data fetching, and Remix provides real-time capabilities for collaborative features through WebSocket servers and Server-SendEvents.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.