Code Bite 🍽: Capitalize Class Declarations

Code should be written cleanly and with consistent style. By following conventions of the language, it is easier to convey the code’s intent and make it more readable for a reviewer. A common mistake amongst new developers is missing on style nuances. One in particular is the capitalization of classes. Capitalizing a class is universally accepted by coding languages to mean a class declaration.

class MyClass {
  var myVariable = nil
}

It is still possible to have a class declaration be lower case, but going against code conventions (especially code conventions across multiple languages) is not recommended.

class myClass {
  var myVariable = nil
}

I remember making this mistake even when I was just starting as a Junior Developer. Unfortunately, it lead to a significant debugging session with a senior developer! If you are currently maintaining a project, take a quick glance at your code and see if you are following the style recommended for your language. More experienced developers can run linters that check your code style for you!

Call to Action

I hope you learned a little more about styling your code!