10

Title says it all. Can't seem to find what is most common out in the world.

I'm brand new to programming.

If the answer is "it depends", I would love to know what it depends on. Here to learn.

28

Stick to the convention of the language and the framework - in your case, React.js seems to be follows the Javascript conventions so there is no conflict. camelCase for variables and functions, PascalCase for types(classes), and UPPERCASE_SNAKE_CASE for constants.

1
  • 1
    Idan, that was the perfect answer I was looking for. Thank you
    – Will
    Aug 8 '16 at 0:35
6

It doesn't matter. All that matters is that you make a choice and stick to it.

When you are using a framework, it can be useful to copy its convention to get more consistent code, but when you are using more than one and they follow different conventions, that's futile.

-2

Software engineers, both new and experts, should use all use a software 'beautifying' tool to clean up their code. I like and use Jetbrains - Resharper. Your entire team should use the darned thing, put away their petty software format eccentricities, and get with the program of making their software homogeneous with the team.

The only way to enforce it is to give up your preconceptions of what you think is 'right' and let a machine force the standard on everyone.

This way the code is consistent and nobody complains because someone indented 4 spaces and someone else indented six spaces ...

1
  • 2
    While I agree with the concept of your answer, this does not in any ways answer the question as formatting tools like Prettier can't fix things like casing. Mar 31 '20 at 16:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.