Ask HN: Have you ever inherited a codebase nobody on the team could understand?
As others have said, I specialize in legacy code.  It&#x27;s the one area you can be an expert in and know 100% for sure that it&#x27;s never going to change ;-)<p>Some quick advice:  Rewrites are almost always a bad idea.  The requirements are almost always at least as difficult to discover as they were in the first place.  You will also miss things or incorrectly decide that something isn&#x27;t important now.  These can often kill your project before you get a chance to replace the old system.<p>But the most important reason for not rewriting is because there are almost always business reasons for extending the existing application during the rewrite period.  This gives you a moving target for the rewrite.  Additionally, you will find that the &quot;legacy team&quot; who is adding code to the existing system will be seen in a better light than the &quot;rewrite team&quot; because they are actively solving business problems.  The &quot;rewrite team&quot; will be seen to have no value until they ship something.  As more and more features are added to the legacy application, more and more resources will be added to it until someday someone will say, &quot;Why are we rewriting this again?&quot; and cancel the rewrite.  It doesn&#x27;t happen every time, but in my career I think I&#x27;ve seen it in about 90% of the rewrites.<p>So you need to get comfortable with the legacy code.  The first thing to do is to make the build and deploy process as painless as possible.  You probably can&#x27;t get time allocated to do it, so with every piece of work you do, steal some time for that.  If you are on a project where they have &quot;build teams&quot; and it&#x27;s actually impossible to build the application yourself, fix that as a matter of priority.<p>Once you can reasonably work on the code, you need to start introducing tests.  The best advice I can give is to read Michael Feathers&#x27;s book &quot;Working Effectively with Legacy Code&quot;.  This is a must read.  I think there may be a newer version of it, but even though the old version is very dated technology wise, the techniques are still rock solid.<p>Fight the urge to refactor&#x2F;rewrite large portions of the application.  Instead, pay attention to the code that you touch the most.  Ensure that this code has good tests and once it does, fence it off from the rest of the code base and start improving it.  Code that you never touch can be the crappiest in the world.  Code that you touch once only has a one time cost, so don&#x27;t fret over it.  Code that you touch every single day needs to be amazing.  Concentrate your efforts there.<p>The last piece of advice I have is to look at the kinds of requests you get.  If you get a lot of similar requests for functionality (for example lots of reports), then make that part of the system easy to work with.  What you want to do is match the ability to work with the code with the expectations of the customer.  If they intuitively think, &quot;This should be easy&quot;, then work hard to make it easy.  Say things to your stakeholders like, &quot;You&#x2F;Users asking for feature X expect this task to be easy for me to do.  It&#x27;s not.  I need time to make it easier.&quot;  Usually they will see the sense in that.  If they expect <i>everything</i> to be easy, use that back on them.  &quot;I can&#x27;t rewrite the whole application without stalling our business plans.  I <i>can</i> make some parts of this easier than others though.  Which parts are the most important?  Note if you say X is important to be easy, then I have to spend time up front to make it easy.  We have to be careful about our budget&quot;.  That&#x27;s the kind of language that business people can understand.<p>Finally, have fun with the legacy code.  You aren&#x27;t likely to make it (much) worse.  Use the opportunity to experiment with new ideas.  However, I caution you to avoid the temptation to transition to newer technologies (you&#x27;ll never  get it finished -- just like a rewrite).  Instead, think about the <i>techniques</i> in the newer technologies and start introducing them in your old code base.  IMHO, this is <i>always</i> more fun that simply using something off the shelf anyway.  Ironically, I find that working on legacy code is the most liberating thing I can do on a professional team.  You can always say, &quot;Well, this is crap.  Anybody mind if I replace it?&quot; and almost always people will welcome it.