How to write identifier names in programming languages (Naming Conventions)

 Naming Conventions in programming languages

Naming conventions are the important thing in any programming language because almost 90-95% of programming languages work with variables, functions, classes, or interfaces. In this article, we will learn about naming conventions. 

We'll deal with 6 different types of things for the naming convention purpose.

1. Packages: The name should be started from popular domains like com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
Example: com.techagency.main

2. Classes: The name should be in the PascalCase (PascalCase is a programming naming convention where the first letter of each compound word in a variable is capitalized). And, the name should be nouns.
Example: class CarFactory

3. Interfaces: They follow the same conventions as classes.
Example: interface CarFactory

4. Method: The name should be in the camelCase and verbs.
Example: runFast()

5. Variables: The name should be in the camelCase and the variable should not start with '_' and '$' although it is allowed but, they are not the right way to define variables in most of the programming languages. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and for characters.
Example: int testMaterial;

6. Constants: The constant should always be in the capital letter. 
Example: OPTION1

Post a Comment

Previous Post Next Post