TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do /you/ annotate a legacy code base?

5 pointsby amflareabout 8 years ago
We&#x27;ve all encountered those legacy code bases that are years old and thoroughly spaghettied. Ideally, you&#x27;d like to go through, reformat it all, leave comments throughout, and generally make the world a better place. However, a &quot;useless&quot; commit like that probably opens the code up to merge conflicts and other problems everyone else will get on your case about.<p>So how have you solved this problem in the past?

4 comments

kenshiabout 8 years ago
&gt; However, a &quot;useless&quot; commit like that probably opens the code up to merge conflicts and other problems everyone else will get on your case about.<p>That is a social problem not a technical one.<p>You need to sell the idea to your team to try to improve the code base with every commit you do. Every time you need to make changes in some source file, see what clean up you can do to it as well.<p>Depending on the morale&#x2F;motivation&#x2F;priorities of the team, this can be a harder sell than it should be.<p>Lead by example. Show good judgement on how much to do. Small changes accumulate fast. Don&#x27;t upset&#x2F;hinder people by changing vast tracts of code that they need to work on.<p>As a great VP of Engineering I once had the fortune to work with told me: Software engineering is a team sport.
Jtsummersabout 8 years ago
It&#x27;s an office politics issue. Here we have little issue with it, but I worked in a place that didn&#x27;t like handling lots of &quot;clean up&quot; commits. The main issue is (working in embedded avionics systems) code changes have to be peer reviewed and qualified. So I&#x27;ve tried to make sure my changes are part of some new or existing PR. I can&#x27;t do it willy-nilly or I&#x27;ll be asked, &quot;Why did foo.c:145-150 change?&quot; If it&#x27;s not part of a PR I can&#x27;t justify it. So when I stumble on problems, I put them in JIRA. Even if the &quot;problem&quot; is: 200 lines of code without a single comment, all variables have names like XYZ12, XYZ13. It may technically work, but no one knows why and, fortunately, falls afoul of our coding guidelines. I may not be able to work it today, but it&#x27;s in the system and can be worked at some point when priorities align better.
marsroverabout 8 years ago
How do you eat an elephant? One bite at a time.<p>Sure, a mass refactoring is going to cause a lot of pain to merge in, but you shouldn&#x27;t be making massive pull requests in the first place. I don&#x27;t think small refactoring here and there should be an issue. It&#x27;s not like we&#x27;ve never dealt with merge conflicts before.<p>If your company is discouraging refactoring because it will cause merge conflicts, that&#x27;s probably not a good sign of things to come.
评论 #13899109 未加载
bbcbasicabout 8 years ago
Refactor code while no one else is working on that module, and ask everyone to pull&#x2F;update once you are done so they start their changes post-refactoring.