I found that the naming conversion of node is a little strange. For instance, in the file system module, the read link function's letters are all lower cased:
fs.readlink
But the read file function's name are camelized:
fs.readFile
It confused me. After mistyping for times, I think I shoud ask. So is there a naming convention to help me memorize the api names?
File names must be all lowercase and may include underscores (_) or dashes (-), but no additional punctuation. Follow the convention that your project uses. Filenames' extension must be . js.
There are no special naming conventions for global JavaScript variables. A global JavaScript variable is declared at the top of a project/file. A global JavaScript variable is written in camelCase if it is mutable. A global JavaScript variable is written in UPPERCASE if it is immutable.
What Is a Naming Convention? In simple terms, a naming convention refers to a framework used for naming your files in a specific way. This should be descriptive and consistent throughout the organization. It is always best to use a naming convention to describe the contents of the files.
A File Naming Convention (FNC) is a framework for naming your files in a way that describes what they contain and how they relate to other files. Developing an FNC is done through identifying the key elements of the project, the important differences and commonalities between your files.
Node's default convention is camelCase. But functions in file system module named according to their respective POSIX C interface functions. For example readdir, readlink. These functions names are well-known by Linux developers and therefore it's often decided to use them as is(as single word), without camelizing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With