Naming conventions make programs more understandable by making them easier to read. Following is a list of commonly used case styles.
Cases
Camel Case
Snake Case
Screaming Snake Case
Kebab Case
Conventions for Popular Programming Languages
Java
Item | Convention | Example |
Class | Start with an uppercase letter. Use nouns for eg. User, Thread, Controller, Service, etc. | public class User |
Interface | Start with an uppercase letter. Use adjectives such as Runnable, Handler, Listener. | interface Runnable |
Method | Start with a lowercase letter. Use a verb such as print(), login(), invoke() If the name contains multiple words, start with a lowercase letter followed by an uppercase letter such as calculateTax() | void invoke() |
Variable | Start with a lowercase letter such as id, or name. Do not use special characters. If the name contains multiple words, start it with the lowercase letter followed by an uppercase letter. | int id; |
Package | Lowercase letters such as java, lang. If the name contains multiple words, separate by dots (.) | package dev.ctrlshift; |
Constant | Uppercase letters. In case of multiple words, separate by an underscore(_) such as LOG_FILE_SIZE | static final int LOG_FILE_SIZE = 18; |
Python
Item | Convention | Example |
Class | Start each word with a capital letter (CamelCase) Do not separate words with underscores. | Model , MyClass |
Method | Use a lowercase word or words. Separate words with underscores to improve readability. | class_method , method |
Variable | Use a lowercase single letter, word, or words. Separate words with underscores to improve readability. | x , var , my_variable |
Package | Use a short, lowercase word or words. Do not separate words with underscores. | package , mypackage |
Constant | Use an uppercase single letter, word, or words. Separate words with underscores to improve readability. | MY_LONG_CONSTANT |
Module | Use a short, lowercase word or words. Separate words with underscores to improve readability. | my_module.py |