Tidying up source code
Oct. 27th, 2018 01:42 pmSometimes I change a bunch of code, get my changes working, then tidy up my mess, even working from the resulting large diff to recreate a series of commits that capture simpler logical steps. In thinking about some code reorganization yesterday I noticed that it includes activities that could be amenable to automated analysis:
Broadly I have the sense that things are going well if my code size is reducing and the average amount of in-scope state is also reducing: then I am mostly left with having to name the subparts. Those measures are among my proxies for if each part of the code is more easily understood and easier to write tests for. I can imagine that there has probably been some active research into the question of automated code tidying to make it clearer though analyzing data dependency patterns, detecting similar code and characterizing its differences, etc. I wonder if it has got anywhere.
This was especially in my mind over the past couple of weeks as I have had to ( do plenty of code tidying. )
Broadly I have the sense that things are going well if my code size is reducing and the average amount of in-scope state is also reducing: then I am mostly left with having to name the subparts. Those measures are among my proxies for if each part of the code is more easily understood and easier to write tests for. I can imagine that there has probably been some active research into the question of automated code tidying to make it clearer though analyzing data dependency patterns, detecting similar code and characterizing its differences, etc. I wonder if it has got anywhere.
This was especially in my mind over the past couple of weeks as I have had to ( do plenty of code tidying. )