Coding Guidelines for Dart
High quality code with good style is not only essential for a developer, but also makes it easier to maintain the software. If you make stable software with good style, then your system will be able to demonstrate high performance.
If programmers use an organized way for writing source code, it will improve source code readability and understandability, and conform to a standard style. This can help avoid introducing errors in the code.
In this blog, we are going to share a few conventions for naming and ordering packages, classes, methods and variables which are in line with best practices.
1. Naming Guidelines
Let us discuss naming, ordering, and formatting code. Before getting into the particulars, it is a good practice to write code in such a way that it should be self-explanatory. The variables and functions should be named based on the operations they are assigned for.
- Packages
Packages and source files should be named using lowercase letters with an underscore. For example, a ‘test driver’ package should be named ‘test_driver’ while a package for ‘dependency injection’ should be named dependency_injection.