If you’ve ever been around developers, you’ve surely heard disaster stories and insider jokes about bad coding practices. This might make you feel that lousy code is imminent and that, if you get into development, you’ll come across bad practices sooner or later. However, that doesn’t have to be the case.
As those very same developers could tell you, software development has a series of good coding practices that most of them are undoubtedly familiar with. They are included in software development courses, shared in development teams, or even learned in the wild. The problem is that they aren’t standardized or formally formulated – they are tricks of the trade that developers are encouraged to follow.
The thing is – many of them don’t follow these practices. For these developers, the only worry is having the final product working as intended, even if it means leaving out comments or bypassing peer reviews. However, ignoring good practices can lead to subpar software that can break at any moment, offer lesser performance, or be hard to update.
That’s why good practices are so important. They serve as guidelines to follow throughout the development to improve the final quality of the code. By adhering to them, teams can get products working while also providing those products with better performance and more robust foundations for updating and upgrading them.
That’s why I thought it would be nice to revisit some key practices that we at BairesDev follow to ensure the quality of our code and products.
Why You Should Use Good Coding Practices
Using good practices feels like an intuitive thing – if it’s something good, then you should definitely use it, right? Unfortunately, my experience has vastly proven that that isn’t necessarily the case in the software development world. As I pointed out before, many developers sacrifice some of these practices to meet deadlines or decrease work.
However, the short-term gains they can get from ignoring these practices pale before the benefits those developers could be getting if they adhere to them. Some of those benefits include:
- Better Workflow: following good practices streamlines all development processes, as the whole team is on the same page about the work they are doing. Teams that follow these practices have better communication, understand each other’s roles, and have better possibilities at prioritizing the work, making the whole life cycle run smoother.
- Increased Efficiency and Productivity: when an entire team follows good coding practices, everyone has a better overall understanding of the project, which leads to fewer errors and a reduced need for constant fixes. That maximizes the efficiency of everything developers code, which ultimately translates into a boost in productivity.
- Enhanced Product Quality: peer reviews and comments allow teams to identify bugs and problems earlier on, which lets them work on fixes before the product goes to production. That means there’ll be fewer issues down the line, which will translate into better performance and a more stable product (that ultimately also means a more robust software).
- More Organized Work: most development teams use management platforms to track their projects’ progress, but they can go beyond that by using tags. Through them, a team can have a more organized file structure, all linked with the tasks at hand. This makes it easier for developers to find what they have to work on at any given time while also helping them better organize their jobs.
- Reduced Costs: all of the above (increased efficiency and productivity, better workflow, higher product quality) converge into this benefit. That’s because a team that’s governed by good practices spends less time fixing things and gets the most out of the time they work on a specific task.
Getting those five benefits should be enough reason to convince any developer or development team to adopt good coding practices. Even if developers don’t care about organization or productivity, avoiding the frustration that comes with having to deal with bugs and errors should be enough motivation to follow good practices.
Now that you understand the importance of good coding practices, let’s review a handful of essential ones.
4 Essential Good Coding Practices
Any seasoned developer might point out that four practices don’t even begin to cover the spectrum of good practices you should be following. That might be true, but for this article’s purposes, those four practices are enough to lay down solid foundations through which you can achieve higher code quality. Also, they are great to illustrate the importance of good coding practices.
Without further ado, the four essential good coding practices include the following:
- Comments: When a developer works on their code, they follow a logic that isn’t always easy to follow by others (or, after some time, even themselves!). That’s why commenting code is such a good thing: it provides explanations of code snippets that can come in handy for other developers that need to rework the code later on.
Comments are simple annotations whose only goal is to make it easier for anyone checking the code to understand what the developer was trying to do. Many developers feel like commenting is a waste of time, but that’s never, ever the case. Even when comments feel redundant, they can serve a purpose, from reminding the developer of the logic behind a line of code to teaching beginners how to do things right.
- Peer Review: another staple of good software development, peer review, implies that all the code written by a developer is always reviewed by someone else. This simple step allows developers to pass their work to a fresh set of eyes that can detect issues with the code more easily and point them out before they become bigger problems. Peer review should be a standard process in all kinds of projects, but its importance in bigger and more complex projects can be understated. If a developer ends up merging a code that wasn’t reviewed, they expose the whole product to potentially more significant problems that can ramp up the costs and efforts to fix. That’s why it’s always best to foster the collaboration between developers to review each other’s code.
- Pull Requests: a pull request happens whenever a developer tells the rest of the team about changes they’ve worked on and are to be pushed to the main repository. You can think of a pull-request system as a warning system in which developers tell one another that there are modifications in the code that need to be reviewed and discussed before being merged. In a certain sense, pull requests combine comments and peer reviews into one practice, even when they aren’t necessarily the same.
- Tags: One of the most neglected practices in all software development, the inclusion of tags is (believe it or not) highly beneficial for the process. That’s because using tags allows developers to quickly identify the different files they work with on a particular project. Thus, they can access them more efficiently while improving their overall organization. Tags can also help identify features, bug fixes, and improvements, which ultimately leads to an index of sorts of all the things covered in a particular project.
Software Development, The Right Way
At BairesDev, we follow a strict policy of adhering to these and other good coding practices to ensure the best results for our projects. The way we see it, these practices are the core of good software development, as they provide higher-quality products that are easier to maintain, update, and upgrade.
Our own experience drives us to be ardent defenders of good coding practices: we’ve seen their transformative power for software development. And that’s why, though we appreciate a good bad coding joke or story, we always treat good coding practices seriously – and why you should, too.