Img source: thoughtco.com

When you are programming, there are cases when you implement something in such a way that it is difficult to understand and reuse by others. As a result, you decide to write comments above it to explain the logic behind your code. The moment you decided to write this type of comment, you admitted that your implementation is already complicated enough so that others or your future self would benefit from adding this plain English type of explanation.

You may add these types of comments, but you should also treat this feeling as a reminder for you to implement a simpler solution for this case. Though it can take more time, and cognitive effort for you to think and understand the problem in a better way to simplify your implementation, these attempts are worth considering.

When you use simpler implementations, you tend to like your code a lot more, as it looks more understandable. You are also helping your colleagues to understand them, so they do not have to feel uncertain to trust and use your implementations in other parts of the projects. Moreover, your future self may work on a certain task that may be connected to this implementation, and it is easier and more enjoyable for you to read a beautiful solution. Furthermore, when you use simpler implementations, you are more likely to avoid potential bugs that may have gone unnoticed with earlier implementations.

The moment you have a difficulty to implement something, you probably Google for a solution. Once you get it, you should not just copy and paste it. You should try to understand it and learn from it. Implementations in different online blogs and communities may vary and there may be ones that are complicated enough, though they seem to accomplish what you are aiming for. It can be easier to just use this implementation without initiating any effort towards understanding and simplifying it, but you should do your best to understand the implementation and simplify it enough so that it is simpler.

Of course, you may be in a hurry, as the deadline may be coming quickly, and you are supposed to get this new feature into production. However, you need to not let this urgent and rare case become your new habit of overloading your projects with a lot of comments and not implementing simpler solutions.

We should not code simply because we get paid for it. We should have feelings for the code that we write. We should treat it as something really precious that we treat with utmost care. We need to be able to treat programming and writing beautiful solutions that amaze other developers, but that also bring value to the clients and customers.

When something seems to be that much difficult, and you consider it to be important, then you should not try to get busy with other things. You should deal with it. As the author of the book ‘The Art of Wary’, Steven Pressfield says, “Like a magnetized needle floating on a surface of oil, Resistance will unfailingly point to true North – meaning that calling or action it most wants to stop us from doing. We can use this. We can use it as a compass. We can navigate by Resistance, letting it guide us to that calling or action that we must follow before all others.”