A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
The goal of a naming convention is to make the code more readable and understandable, which makes it easier to maintain and debug. It also ensures
consistency in the code, especially when multiple developers are working on the same project.
Dart recommends using lowerCamelCase for all non-constant identifiers:
- members of classes and mixins, such as constructors, methods, fields and properties
- top-level functions and variables
- parameters of functions and methods
This means that the first letter of the identifier is lowercase, and the first letter of each subsequent word is capitalized, using no separators
such as _
.
The rule doesn’t check enum
values. Those are implicitly defined as constants, but treated separately
What is the potential impact?
Using the wrong casing can lead to confusion and wrong assumptions about the code. For example naming a top-level function in Pascal Case may
mislead the reader to think it’s a type, like a class or a mixin.