DEV Community

Cover image for A Guide to Coding Standards to Improve Code Quality

A Guide to Coding Standards to Improve Code Quality

Suraj Vishwakarma on June 15, 2023

Cover Image by Freepik Introduction Writing code is easy but writing readable code is tricky. When working as the sole developer, you m...
Collapse
 
middlekerb profile image
Bonifasius Edwin

For naming convention, here is my use case

  • camelCase -> method, variable name
  • PascalCase -> class name
  • snake_case -> database field name
  • kebab-case -> url, branch, folder name
Collapse
 
adarshrajpathak profile image
Adarsh Raj Pathak • Edited

Also, The identifiers with corresponding area that they are specifically used in(or found in)
camelCase ->Java(and many other)
PascalCase -> almost every language
snake_case -> database & python(and some other)
kebab-case -> web-development(HTML, CSS, Js and related tech)

Collapse
 
mrlectus profile image
LectusMan

Kebab for goats

Collapse
 
coderatul profile image
Atul Kushwaha

Hey @middlekerb
Welcome to the community of thriving developers, connect with people, gain knowledge by reading blogs and even create blogs to share your knowledge

All the best

Collapse
 
ekimcem profile image
Ekim Cem Ülger

We all follow this in our team ! exactly the same.

Collapse
 
joebordes profile image
Joe Bordes • Edited

nice article. I agree with almost everything except the comments. IMO comments should be scarse, write code that can be easily read, use comments only when the logic is hard to grasp or you need to convey something to your future self.

Collapse
 
manchicken profile image
Mike Stemle

The problem with writing articles like this is that you’ve got a really good set of stuff that does improve quality (testing, security, etc) coupled with subjective standards (formatting, naming, and comments) which do not improve quality.

The former are disciplines which can demonstrably improve code quality, security, and performance. The latter are opinions that many folks have, sometimes rather strongly, which are a matter of preference, and contribute very little of value to the code. The latter, however, does have the potential to improve the developer experience, which is important.

My advice to most folks: focus on what makes your code better, and then for the formatting just use something that does that for you. If you find yourself spending any meaningful amount of time focused on aesthetic qualities of the text files that make up your application, you’re likely wasting valuable time that you could be using to write more tests which will make your code better.

Collapse
 
panayiotisgeorgiou profile image
Panayiotis Georgiou

thanks for sharing

Collapse
 
jegonag profile image
jegonag • Edited

Follow secure coding practices to protect against common vulnerabilities, such as injection attacks, cross-site scripting (XSS), or insecure authentication. Sanitize user input, use parameterized queries, and validate and escape data to prevent security breaches.
Regards: apk crave

Collapse
 
akpi816218 profile image
akpi816218

I always keep constants and environment variables in UPPER_SNAKE_CASE
class/constructor camel case, capitalized first letter
Everything else camel case, first letter lower case

Collapse
 
adarshrajpathak profile image
Adarsh Raj Pathak

The identifiers with corresponding area that they are specifically used in(or found in)
camelCase ->Java(and many other)
PascalCase -> almost every language
snake_case -> database & python(and some other)
kebab-case -> web-development(HTML, CSS, Js and related tech)

Collapse
 
freddyhm profile image
Freddy Hidalgo-Monchez

Very good points! One thing that is also very important to remember is how readable is the code for the stakeholders (team, group, etc.)

I believe adhering to a style and coding convention can only improve the readability if the stakeholders agree that it does 😛

So having the buy-in from everyone involved is super critical.

Collapse
 
fruntend profile image
fruntend

Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍

Collapse
 
og_dev profile image
OGBONNA SUNDAY

Thanks for this awesome article 🍕. Really insightful

Collapse
 
kalejaiye75 profile image
Kalejaiye75

Thanks for sharing, even if I haven't got to this level, at least I have the knowledge now..

Collapse
 
jerubaalking profile image
Gideon Sainyeye

I usually write ugly stuff that i only can understand then start separating core functions and methods so i can reuse them.... then i start commenting and prettifiyin.