4 Easy Ways to Prevent Common Coding Mistakes
2023-8-27 - Michael Colley
2 min read
It's not uncommon for developers to find themselves repeating certain errors during code reviews and design evaluations. So, how can one make sure that the lessons from these errors are truly internalized? Here are some expert suggestions:
Systematize Your Process: Instead of relying on memory or good intentions, create a structured system. This can be in the form of a checklist, template, or a specific form that reinforces best practices. The Role of Automation: If it's possible, consider automating the creation of certain documents or artifacts. If automation isn't feasible for creation, ensure there's a check to verify its inclusion in the review. Systematizing the process of getting sign-offs can also reduce human errors.
Showcase and Explain Your Approach: During a code or architectural review, if there's a section you're uncertain about, clarify your thought process. By comparing your current approach to past projects and explaining the reasons for your chosen methodology, you can foster both self-understanding and trust with peers during the review.
The Importance of Documentation: It's always beneficial to jot down crucial aspects, especially when relying solely on memory isn't effective. Create a local note, such as "Code Aspects To Check Pre-Review," and list down all past mistakes. Before finalizing your code, revisit this list to ensure no previous errors are repeated.
Harnessing the Power of Tools: Utilize Integrated Development Environments (IDEs): Certain software offers the ability to set custom rules to identify and potentially correct flawed code patterns. Local Linters: Adjust your linting script to include new rules that pinpoint and rectify undesired code patterns. PR Linters: As not all members might run the linting script, an automated linter can be used to go through new code recommendations and highlight necessary modifications. Blocking CI checks that stop you from shipping until certain tasks have been completed successfully, like Jenkins or Pull Checklist
Think Beyond Individual Tasks: It's observed that the most effective engineers often find solutions that don't just serve their personal needs but extend to benefit the larger team. If there's an absence of essential infrastructure, consider initiating and introducing it to the team. This proactive attitude can significantly enhance the overall coding environment for everyone involved. To sum it up, the secret to avoiding repeat mistakes lies in adopting a systematic approach, relying on automation, and cultivating a culture of continuous learning and introspection.