Leave code better than you found it. I heard Uncle Bob say that. I can’t recall if it was a video, blog post, or interview; but it hit me right between the eyes. When I heard “leave code better than you found it”, I was actively developing around code. I saw code that could be better, but left it. I saw code that I didn’t understand. Instead of understanding it and using my code to extend it, I coded around that also.
What really sucks is that I never used to be that way. I became that way. Tight deadlines, working with code I didn’t write, and inexperience made me that way. Inexperience? No, not inexperience as a developer; inexperience working with others. Working with other developers is intimidating. I wonder if I am good enough, fast enough, or even smart enough. It’s easy to try to work faster than I am capable of. The end result is never pleasant. As developers, we don’t get faster by working faster. We get faster by becoming more efficient. No amount of corner cutting will change that. It took one sentence for me to be reminded of that.
It doesn’t take much to leave code better. Reduce database calls or HTTP requests, add some caching, optimize a block or loop, or DRY something up. You don’t have to refactor the entire application. Just refactor one method. Speaking of methods, this applies to more than server side code. Front end code needs this too. Simplify an HTML element, remove divitis, or reduce CSS duplication. Again, it doesn’t take much. Just think if you did this every time you opened a file. Software would continually get better and would be generally more pleasant to use.