4 ms·
After you get done writing a section of code, take a few minutes to look at it and see if there is any way it can be improved. Move functionality around, rename
by ktRolster 11y ago
After you get done writing a section of code, take a few minutes to look at it and see if there is any way it can be improved. Move functionality around, rename some variables. Do it right away, while it's still fresh in your mind.
- collyw 11y agoI find the best time to do this is when I come back to code that I wrote a few months ago. If it doesn't make sense immediately, then it probably needs refactored (I wrote the code I ought to understand it quickly). Ideally it should be refactored right away as you say, but often it takes forgetting the code, then rereading it to see how unintuitive it was the first time.
- kentt 11y agoI like that tactic. I will steal it. In a similar vein, I like to take a break if possible, before a larger commit, then come back to it and see if I should refactor first. Two benefits of this are (1) a fresh mind to see what you might have missed especially since when I'm done with a piece of functionality I often just want to commit it and move (2) it gets me back in the flow of development quickly.