Cutting Too Many Corners?

I’ve always enjoyed developing small applications to make life easier, but they were sometimes more of the “cowboy” variety. They didn’t go through the full development process that they should have gone through. Instead, it was a situation of putting together something that just works and rolling with it.

For the most part, the risk involved was low. These weren’t projects that were going out to hundreds of clients; they were internal tools or something for me to toy around with locally.

I’ve been involved with more official development work on top of database responsibilities in the last few months, which led to the recommendation to read Clean Code by Robert C. Martin. It’s an older book published in 2011, but plenty of rules and guidelines still apply. Along with the more technical details, one area jumped out at me in Chapter 12 that can apply to anyone writing code, queries, or scripts:

Most of us have had the experience of working on convoluted code. Many of us have produced some convoluted code ourselves. It’s easy to write code that we understand, because at the time we write it we’re deep in an understanding of the problem we’re trying to solve. Other maintainers of the code aren’t going to have so deep an understanding.

and

All too often we get our code working and then move on to the next problem without giving sufficient thought to making that code easy for the next person to read. Remember, the most likely next person to read the code will be you.

I don’t feel like it’s out of the ordinary to go look at something you wrote years ago, wonder why you wrote it the way you did, and see improvements that can be made. I have done that many times. But that doesn’t mean you shouldn’t give your best the first time around.

Use better names. Comment when necessary. And if possible, optimize now rather than later. A query might be fast with your 100 rows of test data. Can it be improved now so that it will handle 1,000,000 rows?

If you’re looking for something to improve in 2024, consider being more thoughtful about what you’re writing and making it the best it can be. It may take longer to complete. It may mean another task on your list has to wait a bit longer. But as the quote mentions above, the most likely next person to read the code will be you, so give your future self a break.

Thanks for reading!

One thought on “Cutting Too Many Corners?”

Leave a comment