In this blog we are going to have a look at Best Coding Practices!. So let’s dive straight into it.
Being the software developer (aka Coder/Programmer) is not an easy task. You have to think a lot before developing any product (Website/App/Software) to meet the end user’s requirement. To achieve what they need is bit tricky. And, that is what why we get paid!. While trying to meet the end user’s need we might get distracted from making the code base clean and structured.
Following are some of the best coding practices while coding. These are the guidelines that we have to follow. They help us to reach our goal without making our code STRANGE.
1. Google IT! 😇
If you want to build something then just first google it. As the world is so big and there are chances that whatever you are building may be built earlier. And possibilities are that may be open source. So rather starting everything from scratch, you might get some idea or code to start with. Google is your Friend and Philosopher. It knows what you are looking for so give it one try. Also, while development, use google to search for any kind of help you need. I am damn sure it will help you.
2. First Solve Then Code! ✍️
Even when I started coding, I usually used to code first and then think on it. Frankly, That’s a bad way to go. First, you have to solve the problem on paper. I mean to just think on it how we can solve this. The possible ways to achieve the solution. And then figure out what’s the best solution to the given problem. Thinking before coding will definitely decrease your lines of code(LOC).
3. Keep It Simple And Sweet (KISS) 😘
A programmer writes the code that machine understand. And, the best programmer writes the code that everyone understand. To be such programmer you must keep the things simple. Keeping things simple allows to modify part of your code without distracting other part so much. So make sure to keep your design and code simple and sweet.
4. Naming Conventions🐪
I see lots of people not following the naming convention rules. That surely affects the code’s readability and maintainability. As your variable, method and class names does not relate to what you are developing. So understanding of your code is much difficult than starting it fresh again. So do follow one of the naming conventions. I use and suggest to go with the camel-case convention, As its widely being used.
5. Modular Structure👨🌾
You can’t build the entire elephant in single go. So just start with the pieces or components and then finally combine them together. Modular code development and structure gives power of separation of concern. It allows you to build the modules separately and independently regardless of inter dependencies. This also avoid the bugs as you have to build the small piece of code, test it and deploy. This also allows to reduces repeated code and reuse the existing code. And, lowering the no of lines of code of the project.
5. Code Reviews / Code Refactor / Pair coding 🧐
Multiple eyes looking at the same problem, come up with different possible solutions. So this can lead you to more accurate and precise solution to the problem. And, thus you can provide the best solution to it. Also pair coding or regular code reviews refactors code style, minimizes bugs count and improves individuals skill set. It also helps to keep the code base clean, updated and minimize the lines of code.
6. Code Comments / Documentation 📖
As said earlier, “Best programmer write the code that people can understand!”. Doing that is not so simple but you can use the comments to tell other people why and what you are doing. This let’s other people to understand the code. Try to keep the documentation of your code to avoid the confusion and logic loss. But good code is its own best documentation. As you are about to comment, ask yourself: “How can I improve the code so that this comment isn’t needed?”.
There are some more also. We will discuss those later. Till then keep check other blog posts.