Coding Best Practices

Best Practice Inscription on Modern Style Illustration. with Green Arrow and Hand Drawn Icons Around.

Coding is the process of writing instructions for a computer to produce specific output. Just like learning proper English in school, it’s important for coders to follow coding standards and best practices to improve the quality, readability, and maintainability of their code. Here are five best practices to follow in your coding journey.

1: Add Comments to Your Code

Writing comments in your code is a simple and effective way to increase its readability. Comments are notes to yourself and others who may read your code, providing explanations for specific sections or actions. Comments can be written as single-line or multi-line, and different programming languages have different ways of writing them. For example, in HTML, comments look like this: <!-- Comment goes here -->, while in JavaScript, single-line comments are written like this: // Comment goes here, and multi-line comments are written like this: /* Comment goes here */. Most text editors, such as Visual Studio, Atom, or Sublime, have a shortcut key for commenting, such as the command-slash key in Visual Studio.

2. Adhere to Best Practices and Guidelines

Just like learning grammar in English class sets a standard for proper speech and writing, coding best practices and guidelines set a standard for writing clear and maintainable code. Ignoring these standards can lead to a chaotic coding environment where it’s difficult to understand what’s been written. It’s important to follow the best practices and conventions specific to the programming language and project you’re working on. Many software companies have a coding standards document that outlines the guidelines for developers.

3: Follow Naming Conventions

Different programming languages have different naming conventions, such as camel case in JavaScript, snake case in Ruby, and capitalize in Java. Following these conventions can increase the readability of your code, but they are often not mandatory. However, it’s still a good practice to follow the widely accepted conventions in your language of choice.

4: Avoid Repetitive Code with the DRY Principle

The DRY (Don’t Repeat Yourself) principle encourages coders to avoid writing repetitive code that does the same thing. Efficient coders write code that is concise and accomplishes a lot with few lines. When I first started coding, before I learned loops, I created a game of rock, paper, scissors. Upon revisiting my code I was able to reduce 100 lines of code to a mere 12 lines. The reason was that I was repeating a lot of the code that could have been simplified with a loop.

6: Never Stop Learning!

The tech world changes quickly, and it’s important to keep your technical skills up to date. For example, the JavaScript of today (ES6) is not the same as it was 20 years ago, with new methods added, some deleted, and the addition of classes, arrow functions, and more. To stay relevant and write code that is up to date, it’s important to continuously learn and update your skills. Subscribe to reputable coding forums and sites, and consider taking online courses or attending tech conferences to expand your knowledge.

I am a full stack web developer living in Costa Rica. I enjoy creating websites and apps. I am fluent in Spanish, English, and Japanese. My past experience includes 13 years in the US Navy, and 2 years of Social work. My hobbies are watching anime, playing video games, and spending time with my kids. This is my blog where I write about my experience as a web developer.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Site Footer