Writing Clean Code
As a Software developer, many a times, we receive the code review comments, which are not very clear e.g., the reviewer says — the code is not properly commented, but what are the proper comments? We get the feedback is that the code can be optimized — but how?
Review comments in Object Oriented Design are even more abstract. Reviewer says — Class design is not correct, but designer thinks — What is the problem? Comment is — Inheritance is not used properly, but designer thinks — there was a clear “Is a” relationship, then why there is a problem?
Do you face these problems? As a Software developer, we do know how to write code, we know the programming language. As a software designer, we know how to design classes. However, the problem is that we only know them, but we understand them only a little. The difference of knowing vs understanding causes all the difference. 😊
This understanding can take us to the next level. We start writing quality code and quality design. It separates us out from the crowd.
First step in any improvement is not to make mistakes, especially multiple times. We need to learn from others, what they teach from their own experience and what they suggest. Charlie Munger says “All I want to know is where I am going to die, so I’ll never go there!”.
Next step is to learn the best practices of any trade. The Best practices have become the Best because they have brought success to many. They have been proven to the field. Reusability is a big aspect in any industry including software. Then why not use what others have already discovered. We do not have the lifetime to discover everything ourselves. However, we do have the time to learn from others and add to it.
Finally, there are some principles and patterns which occur repeatedly in any trade. Not even in trade, but our day to day life as well. First time, we face a problem, we do not have any clue to solve it. Once we get to know the tools and methodologies to solve it, our fear of that problem goes away. Next time, we face that problem or other similar problem, we know how to deal with it and in an effective manner.
In summary, we write the code, we build product. It is good, but it is not enough. Earlier we learn to write the code in a good way, we adopt best programing practices, we learn the principles and patterns, we build our foundation strong, we stand a strong chance to build a successful career.
About the Author:
Gulshan is a software developer and architect with about two decades of experience. He loves teaching and has published a few courses on Udemy and Shikshaspace. You may find his course on Design Patterns here.