I look through commit messages and try to link it up to a Jira ticket and piece it together. Often the original developer has left, or if they are still present doesn't remember why. Most of the time I don't know why something was done a particular way .
Ask HN: How do you find the "why" behind old code decisions?
31–40 of 44 posts
Re: Ask HN: How do you find the "why" behind old code decisions?
#32We're more diligent about ticket descriptions these days, but we weren't always. Obviously the best is to be able to to talk to people, followed by documentation, either explicit documentation or on the ticket itself .
After that it can be useful to look at all commits that were related to the change itself. You can often piece together why something was done from looking at how the changes happened as whole, or even which parts were rewritten as requirements changed.
Another option is to talk to people in your org closer to clients. Support or client managers can sometimes have a better idea of how features are actually used, meant to be used, or what parts are more valuable than product or engineering will, especially if they're revisiting a feature for the first time in many years.
But yeah, often you can't. You're best bet then is to make sure you really understand the feature look at it with fresh eyes. Say "Well this is how it DOES behave, how do we want it to behave from here?" Actually talking to clients can be helpful here if any of them are willing to talk to you. In enterprise software, you can probably find a client who wants to shape the direction of the feature and has some strong thoughts.
Re: Ask HN: How do you find the "why" behind old code decisions?
#33Re: Ask HN: How do you find the "why" behind old code decisions?
#34Re: Ask HN: How do you find the "why" behind old code decisions?
#35This thread makes me think of when I was refactoring a COBOL application when I just started my SWE career in 2016/2017. The original program was from 1989 and things like git blame, ticket systems etc. wasn't there. There was rudimentary version control, but that didn't go back to far, and also surprisingly there was some documentation. But the major thing that helped me answer the "why's" was that the original prog…
Re: Ask HN: How do you find the "why" behind old code decisions?
#36The diff tells the 'what' - no point in writing 'added method bob()'
The message tells the why.
You can bet that over time, the jiras, the issues and the confluence, slack, o365, will all have been deleted, "upgraded" or whatever, and all you have is what's in the repo.
Using in-repo ADR, and in-repo 'what's missing, what's next' files are also useful, because they co-evolve with the code.
Re: Ask HN: How do you find the "why" behind old code decisions?
#37Re: Ask HN: How do you find the "why" behind old code decisions?
#38The honest answer is you probably won't find it. Historical documentation is hard, it is the first "features" cut when teams are scrambling to meet a deadline. There is no malice in this, it's just something that the end user doesn't need or see so when shit hits the fan, it get skipped. Commit logs, slack/email/etc, documentation silos, or issue trackers are your best bet, other than actually being able to talk to t…
Re: Ask HN: How do you find the "why" behind old code decisions?
#39So in practice it was usually not too bad. Git blame on any line could point me to the PR and any associated ticket.
You just need to have some discipline among the team because there would be slackers who didn’t want to take an extra 5 min. But you know. You weed them out.
Re: Ask HN: How do you find the "why" behind old code decisions?
#40- Every change beyond the most insignificant package bump should be ticketed, and specifically tickets should document the business why.
- Every PR should include a high-level description of the change, and should document any technical whys. It should also link to the ticket.
- Code comments should be used where appropriate to document code-level whys and hows.
- For significant architectural changes ADRs should written up to document why the architectural change was made.
Failure for your team to do this results in the problem you're experiencing now.