What’s a best coding practice and when to create it?
A best coding practice is a specific action in a particular context, it’s a way of doing things to achieve a specific result. These practices differ between companies and sometimes even between teams within the same company.
Unfortunately, it’s rare that static analysis tools (linters) can automatically identify all these coding practices, which go beyond the syntax of the code. That’s why it’s crucial the whole team is aligned with them.
With this in mind, we created Packmind, a solution that centralizes your team’s best coding practices.
A coding practice in Promyze is made of:
- a name
- a description
- categories
- code examples (positive, negative, and refactoring)
Why define and share best coding practices?
As companies aim to deliver value as quickly as possible and avoid bugs that are harmful to their business, they must capitalize on the collective intelligence of all their teams.
Accelerate has highlighted in its study that the most successful companies from an IT point of view have implemented a “Learning Culture,” which promotes continuous learning and knowledge sharing. This helps to cope mainly with:
- Heterogeneity of skills in teams — everyone can learn from the skills of their colleagues and thus strengthen the team’s skills as a whole.
- Turnover — newcomers can quickly become familiar with the company’s practices, which reduces adaptation time and the risk of losing skills when they leave.
- Rapidly evolving technologies — best practices are constantly being renewed, new languages and frameworks appear regularly, so it is important to stay up to date with this. Moreover, on a personal level, this allows developers to remain competitive in a constantly evolving market.
When to create a best coding practice?
For the whole team to contribute to this knowledge sharing, everyone must have in mind “when” he can create a practice.
In order not to leave the working environment, it must happen when you’re writing code (from your IDE) or when you’re reviewing code (on a merge request in GitLab, for example).
Packmind plugins make this creation easier by allowing the team to create these practices in seconds.
2 main scenarios should lead to best practice creation:
- A bug has been identified that stems from a poor design or code error;
- An improvement has been made to the source code
Case #1: A bug has been identified that stems from a poor design or code error
“One should always learn from your mistakes.”
Strongly linked to the “Dantotsu” approach, the idea is to use each bug as a learning source. Each problem is then presented to the team, and one or several practices can emerge from these discussions.
This is obviously also true for potential bugs that could be avoided, for example, if they’re identified during a code review; in this case, the Promyze plugins allow you to create this practice directly when you add a comment during the code review.
For example: A bug is identified in an AngularJS component, a disconnection should have occurred when the component is destroyed.
And here is the associated fix to follow the best practice.
Case #2: An improvement has been made to the source code
Because the source code is constantly evolving, our practices are constantly being challenged. When a practice evolves, it’s rare to modify the entire source code of the product to follow it. It’s, therefore, common to find many different ways of doing things in the same source code.
When a practice evolves, it must be presented to the whole team, and this change must be recorded somewhere. Otherwise, it’s only local and doesn’t last over time.
These practice changes can be of multiple natures, for example:
- A new concept is introduced in the codebase
Adding a new system in the app, to call when adding a new object.
- Improvements in the code architecture
Setting up a new pattern to highlight the infrastructure layer level.
An example that features the outdated convention.
- Performance, security, and accessibility improvements
- Maintainability improvements (such as better readability of the source code).
Sure, we could list a few more, but these four examples are the main ones that would make your team want to start sharing best coding practices.
Wrapping up — start sharing your best coding practices now
In conclusion, it’s key to share practices within the team to improve the lead time and reduce the change failure rate. Tech leads must be the drivers and ambassadors of this approach to boost the involvement of the rest of the team.
It’s important not to overestimate the knowledge of other team members. Known as the Curse of knowledge, this phenomenon translates into the tendency to think that other people know the same things as we do, so we limit the practices to be presented, even though some of them are probably unknown to our colleagues.
These practices should be shared with all the teams in the company and not only with your team. They’re also valuable for the next team members, so we must think beyond our team when we identify a coding practice.
Want to discover a new way to share your best coding practices as a team? Start now for free with Packmind.