+ Start a Discussion
teena jacobteena jacob 

Group apex classes like packages or namespaces

Hi,
  Is there any way to group apex classes like packages or namespaces.

Thanks.
Best Answer chosen by teena jacob
Khan AnasKhan Anas (Salesforce Developers) 
Hi Teena,

Greetings to you!

Apex classes are stored in the classes folder in the corresponding package directory. You cannot create a package in Salesforce to put your class. Salesforce put all the classes in a default folder. Apex classes doesn’t support nested namespaces or packages like Java to organize code in a clean way.

You can use the naming convention for your Apex Classes i.e.; use some specific keyword when creating classes:
  • Prefixing class names: 
    {prefix}_classname.cls
           eg.: page_AccountTable
                  trgr_AccountDuplicate
 
  • Suffixing class names: 
    classname_{suffix}.cls
           eg.: AccountTable_page
                  AccountDuplicate_trgr


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas