One way or another, we encounter legacy code. I used to think that the legacy code is old-fashioned, so it needed to be refactored. I tried to persuade the company to refactor the legacy code with new architecture and language. But the company declined my proposal because it is an unnecessary work. After a while, I realized that the company was right. It was, and is still unnecessary to touch the legacy code.
The clients pay for the services that are built with the legacy code, so the company is able to give me a paycheck. It has already proven itself in the market. It is unnecessary for the company to take a risk to refactor it on purpose. The company always makes the best out of it with a limited amount of time and resources. It is more reasonable to focus on launching new services rather than refactoring a stable codebase.
If the code is still where it used to be, and it is still widely used, it's because it's okay to be a standstill. It depends on how we see ourselves as a programmer, I don't think programmers are people who isolate themselves from the world and just obsess over technology. A programmer stands at the boundary between the market and technology, constantly figuring out the best balance that satisfies both sides through code. In that sense, maybe legacy code is not just old or outdated. It is the result of trade-offs of adjusting speed, priorities, constraints and timing to fit the situation at that moment.
일을 하다 보면 어떤 형태로든 이전에 작성된 레거시 코드를 접하고 유지보수 하는 경험을 하게 된다. 처음 회사의 레거시 코드를 보고는 시대에 뒤처진, 개선이 필요한 코드라고 생각했다. 그래서 새로운 구조와 언어 도입의 필요성을 설득하려 했다. 하지만 회사는 '불필요한 작업'이라며 받아들이지 않았다. 시간이 흐르고, 나는 회사의 판단이 틀리지 않았다는 것을 깨달았다.
레거시 코드로 구축된 안정적인 서비스에 고객들이 비용을 지불하고, 그 수익으로 회사는 나에게 급여를 지불할 수 있기 때문이다. 이미 검증되어 안정적으로 동작하는 코드를 새로운 구조와 언어로 대체하는 일은 회사 입장에서 불확실성을 높이는 선택이다. 굳이 위험을 감수할 이유가 없다. 또한 회사는 제한된 시간과 자원을 최대한 효율적으로 배분하여 최대의 성과를 내야 한다. 회사 입장에서는 레거시 코드 리팩토링 대신 신규 서비스 개발에 집중하는 것이 합리적인 선택일 것이다.
레거시 코드가 아직까지 유지되는 이유는 거기까지만 해도 되기 때문이다. 자신을 개발자로서 어느 포지션에 두는 가에 따라 다르겠지만, 개발자는 세상과 단절되어 기술 개발에만 몰두하는 사람이 아니다. 개발자는 시장과 기술의 경계선에서 끊임없이 양쪽이 만족하는 최적의 접점을 기술로서 풀어내는 직업이라고 생각한다. 그런 의미에서 레거시 코드는 낡은 코드가 아니라 완급 조절의 결과물 이라고 이해하는 것이 더 적절하지 않을까 생각한다.