I have been programming for quite some time now along with managing a team of some good developers. After many app crashes, maintenance problems and performance issues, I have tried to write down a few practices that my team and I have learned. These are very basic in nature and are extremely helpful when multiple people intend to work on the same project.
1] Code formatting
This is the first and foremost advice I give to developers of all groups i.e. freshers, mid-level or highly experienced. A code that is readable by self and others is also maintainable. Below is an example of an unformatted code and a formatted one
In case you’re not sure how to format your code, you may look out on google for some handly tools online with the search phrase “online code formatter” or “online code beautifier”
2] Early Exit
We often write code that has a lot of conditions and statements. After the lengthy reading, the code seems to be too complex or tricky to understand. Early Exit a.k.a. Early Return policy expects developers to write code in a way that invalid conditions get out of the way at the beginning of the function
If you’re a developer working on multiple technologies, workspaces are for you. Even if you’re working on a single technology, you should use workspaces. Workspaces are nothing but directories for every technology. They help in keeping the projects isolated and easy to recognize when the same project is developed in more than two technologies.
I prefer creating a directory for each technology in the Documents folder.
4] Boolean comparison
Boolean comparison is easy. But it can be made easier
5] Naming Conventions
This is one of the most commonly discussed topics. Not much needs to be explained here though 😃
We often pick snippets of code from blogs and websites. Many times, these snippets are used as-is and don’t require a single character change.
Always add a reference to these code snippets so that you may refer to the updated version of the same code snippet later on. Another benefit is that any other developer who looks at your code will be aware that you are not the original author of the code, in case it needs to be improved.
At times, we write quick and dirty code as the time available is short thinking that the changes can be done later on. Most of the times, this later doesn’t come at all as programmers tend to forget the things that were left to be changed.
The approach that I follow here is to mark the piece of code with a TODO remark/comment. Later on, I just search for TODO in the entire project and get a list of codes that need to be improved
Feel free to comment if you think there are some other recommendations that need to be added.
8] Use correct data types
When everything is string, simple comparisons become difficult. One has to typecast to get the correct value, boolean “true” does not equal 1 or true and many more. I strongly recommend using the correct data type for a variable/attribute that defines its purpose.
9] Update tools and software
When your software is shipped and used by many of your clients, it seems scary to update the tools and packages as they may break some functionality. However, in my experience, I have seen that many of the security issues and performance improvements (that you may never think of) are automatically added to your software when the underlying tools and packages are updated to the latest version.
It is, however, strongly recommended to follow the below to minimize the effect of the update to the working software
a) make the updates in an isolated environment
b) get the software regression tested
c) read the changelogs/issues of the version of the package/tool that is being updated
10] Read articles and open-source code
Make a habit of reading technical articles and explore open-source code on a daily basis. You may begin with sparing 30 minutes a day for the first few weeks and increase the duration later on. Below are a few benefits
b) Open-source code: Exploring the source code will inspire you on the coding styles and patterns used by different developers around the world. To start with, one may visit Github Trending section
11] Write on paper first
I realized it quite late, however, I feel the best way to solve any programming problem is to use the most basic but the most powerful tools i.e. a pen and a paper. You can write or draw the possible solutions, pseudocode, and everything related to it before converting it into source code. Below are a few benefits
1) You spend less time staring on the screen
2) Your thought process on a paper will be natural than what it is when in front of the screen
3) You can brainstorm more ideas
4) You can avoid writing correct syntax. Minor issues won’t irritate you
Once you are confident about your solution, you can begin writing the awesome code for it.
12] Give back to the community
- A programmer searches for solutions to programming problems in blogs and forums.
- A good programmer posts questions related to programming problems in blogs and forums.
- A wonderful programmer answers of questions related to programming problems posted by other programmers.
One may have achieved many heights in programming and technology. But the journey is incomplete if nothing is contributed to the programming community. I strongly recommend programmers of any experience to post answers to other’s problems and help them. One such forum that I recommend is StackOverflow. It’s easy… it’s fun… but most of all, it’s satisfying… 😇
13] Solve problems
I have to admit — this is not my original idea or experience. A dear friend of mine suggested this to me and convinced me immediately.
A programmer, be it of any experience, should always spend time on solving problems. The problems could be easy or simple.
But how do we find problems? That’s easy. There are a couple of developer sites that can be of really great help. One such site is HackerRank. This site has tons of problems that are waiting to be solved, right from the beginner to the expert level.
So, get going to solve some really interesting problems