DEV Community

Cover image for The Most Important Coding Guidelines

The Most Important Coding Guidelines

Patrick God on September 15, 2017

C’mon, it’s not that hard. When you start a new job or project, when you enter a new team, it is really helpful to agree on some coding guidelines....
Collapse
 
dijitalmunky profile image
Chris Roe

Great article! My programming "childhood" was during the first dotcom boom, and I was raised on mantras of "Thou shall not violate the standards". Of course that led me to desire enforcing standards. Thank goodness I saw the light!

These days, I lead a team where we are mostly not picky about coding style. If one of us reviews code and we can't get a good sense of it's purpose within a moment or two, we call it out to each other (nicely of course). The result? A much happier, trusting and performant team...something that I didn't expect.

Collapse
 
_patrickgod profile image
Patrick God

Thanks, Chris. And thank you for sharing your experience. Sounds great! :)

Collapse
 
bosepchuk profile image
Blaine Osepchuk

Nice list, Patrick.

If there was room for one more thing on your list I would vote for automating your rules with some kind of static analysis tool.

Have you tried that? If so, do you have any tips?

Collapse
 
_patrickgod profile image
Patrick God

Thank you, Blaine!

There are several tools that can help you writing readable code. ReSharper and the integrated StyleCop are tools we use in our team. For instance, it reminds you of proper naming or even using simpler code sometimes.

But the KISS thing is something you learn with experience I think. You can even do it completely by yourself. Look at code you wrote weeks ago. If you still understand it in a minute, it might be good code. Too often we write complicated algorithms that seem pretty clever but are so hard to understand that you don't know what your past self actually did there.

However, regarding KISS you have to be careful with ReSharper. Sometimes it wants to replace your for-loop with a "clever" LINQ statement, but as mentioned above, this replacement can lead to unreadable code.

Hope this helps! :)

Collapse
 
fortegabbm profile image
ferOrtega

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Martin Fowler dixit.