There’s no one right way to write neat code, but being neat is a good idea.

I was in search of some guidance on good practice for writing code. These are some references that I found (and I will add to if I find others that are useful).

Some references:

Is there a right and wrong way?

It would seem from my reading that there are various ways you can do your code, and no one that is the correct method. The key is being consistent. So indent in the same way throughout. Use the same naming conventions. And put comments in to help you and any other developer identify what each bit does. But don’t label the obvious.

Commenting out

I have already discovered to my cost that commenting out syntax is different for HTML, style and script.


   



   

   

Refactor regularly

This advice relates to cleaning up your code from time to time. “Over time websites and code bases continue to evolve and grow, leaving behind quite a bit of cruft*. Remember to remove old code and styles as necessary when editing a page. Let’s also take the time to evaluate and refactor our code after we write it, looking for ways to condense it and make it more manageable.”

* badly designed, unnecessarily complicated, or unwanted code or software

Keep example snippets

It strikes me when learning that it makes sense when you make a particular element work the way you want, it is worth keeping the snippet of code in a ‘library’ to look back on. Of course that could be in a blog like this to also let other people find it.

You may also like...

Leave a Reply