Naming convention in Salesforce is a rule to follow as you decide what to name your identifiers like class, variable, constant, method, etc. But, it is not forced to follow. So, it is known as convention not rule. Naming conventions make the application easier to read and maintain.
APEX NAMING CONVENTION:-
Class Name: Class names should be unique, beginning with an uppercase letter. It should NOT contain underscores or spaces (except from the prefix and suffix). Class names should be nouns in mixed cases, with the first letter of each internal word capitalized.
Example:- Employee
1 2 3 4 5 | public class Employee{ // write your data members and members functions } |
Variable Name: Variables should be in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should be short and sweet and meaningful. Its should be camelCase like contactList
Example:- contactList
1 | List<Contact>contactList= new List<Contact>(); |
Method Name : Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Whole words should be used and use of acronyms and abbreviations should be limited. Name should be camelCase like
Example:- showAccountDetails
1 2 3 4 | public static List<Account> showAccountDetails() { // write your logic here... } |
Constants: The names of variables declared class constants should be all uppercase with words separated by underscores (“_”). All uppercase letters in this format: CONSTANT_NAME Example:
Example:- CONTACT_LIMIT='10';
1 | private static final CONTACT_LIMIT= '10' ; |
Here is the table you can see and apply in your code:-
Contact Me -
Salesforce Hunt Social Media Handle
🔔 Subscribe to my YouTube channel
https://www.youtube.com/c/SalesforceHunt
📌Website
📌Blog
https://salesforcehunt.blogspot.com
📌FaceBook
https://www.facebook.com/salesforcehunt
📌Linkedin
https://www.linkedin.com/in/salesforce-hunt-b6aab3227/
📌Twitter
https://twitter.com/salesforce_hunt
📌Instagram
https://www.instagram.com/salesforcehunt
📌Pinterest
https://in.pinterest.com/salesforcehunt
📌Quora
https://www.quora.com/profile/Salesforce-Hunt
📌Telegram
https://t.me/joinchat/fccG1UqNg1dhMTQ1
📌Reddit
0 Comments