Me and Legacy code — Issue 1
During my tenure in NFN Labs, Myself and Jaison Fernando would discuss variety of things. One thing I was never able to find an answer is that “What is the strangest issue you faced?”. To be frank I never got an interesting issue till that time to say “I faced this issue which is wired”. But now I have one. I hope next time interviewer asks me this question.
Problem
There is this module in an android app where no one have changed a line in a year. I have no idea how things work in the app since I am pretty new to the code base. Fortunately, my colleague was working on the new feature in that module.
When we are catching up as a team, we come to know there is this issue in our app. Edit Text is not gaining focus and keyboard is not showing and Edit text are in Recycler view.
We were discussing possibilities why this is happening and 2 days went by. A day before the delivery of the build, we were yet to resolve the issue.
We thought, it’s good that someone else look into the code and try to understand this issue. So, I was looking into the codebase and it took me half hour to find the file from where the screen is rendered.
Get Balakrishnan’s stories in your inbox
Join Medium for free to get updates from this writer.
Fast forwarded to 5 hours, after digging to 2 View Pager and 5 fragments and n number of xml files. I had a clue, on clicking the Edit text Click Listener is triggered but focus change listener is not triggered. Okay, this means there is something do with the focus.
There is this single line android:descendantFocusability="blocksDescendants" in an xml file that is generated dynamically where Recyclerview is being added. Hola issue is fixed. We knew that this is a single line issue.
Working in legacy code is harder. But, Working in non-documented code? Imagine you are in a maze and trying to escape with your eyes closed that's how it is.
What we can to do find single line in 125k loc in java and 33k loc in xml.
- Add inline comments — Just answer why and what of the class and method
- Follow the existing architecture if there any
- If you are updating the architecture to newer or fancier one, Move your entire code to new one
- Add a valid commit message to the fix you have given








