DEV Community

Sarah Dye
Sarah Dye

Posted on

5 Best Practices Developers Always Follow

If there is one thing I’ve learned about coding, code isn’t going to work 100% time. That is what makes it challenging and can frustrate any developer no matter how much experience you have. Skillcrush has a list of tips to help newbies avoid future mistakes or what to look for if something doesn’t work in their code. These tips are:

1. Keep the code nice neat and tidy!

If you look at your code and can’t read it, it will be harder to spot mistakes in your code. As you code, try keeping your code organized and clean. That means making sure nested elements are indented.

2. Mind your syntax.

One little mistake in code can easily take down an entire website. Therefore you want to spot syntax errors as you code. Common beginner mistakes might be misspellings, missing punctuation marks, and incorrect closing tags. If something isn’t working, Skillcrush suggests checking for these errors first.

3. Get to know (and love) online resources.

There are lots of HTML tags so it is impossible to memorize them. However, coding does take lots of practice, and each time you code you will get better using these tags. If you need to find some code or tags, there are tons of online resources available to help developers. Other developers often use Google to help them find solutions or code they need to build a website.

4. Validate, validate, validate!

If you still can’t figure out what is wrong with your code, developers use an HTML validator. Validators find errors all the errors in your code for you. All you need to do is give the validator your HTML file or a URL then it finds all the errors in your code. There are free HTML validators online developers can use to check their code.

5. Comment your code.

Developers use lots of comments in their code to help communicate with other developers. If you are working on a team, comments will be a big way to communicate with developers on what code is trying to do or where it might come from.

<!-- This is a comment for a single piece of information -->

<!-- This is a comment for a larger piece of information.
1. This item
2. Or this item.
Don't forget to close your comment when you are done.-->
Enter fullscreen mode Exit fullscreen mode

To make single comments like in the sample code above, you use <! following two dashes to tell the computer you want to create a comment. When you want to end your comment, you use two dashes before the > to indicate your comments.

Comments won't be shown on a browser. If you want to see comments developers have written, you have to look at the code. If you right-click and view a website's page source, chances are you will find some comments mixed in with all the lines of code.

Top comments (0)