You need to sign in to do that
Don't have an account?
teena jacob
Group apex classes like packages or namespaces
Hi,
Is there any way to group apex classes like packages or namespaces.
Thanks.
Is there any way to group apex classes like packages or namespaces.
Thanks.
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:
eg.: page_AccountTable{prefix}_classname.cls
trgr_AccountDuplicate
- Suffixing class names:
eg.: AccountTable_pageclassname_{suffix}.cls
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
All Answers
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:
eg.: page_AccountTable{prefix}_classname.cls
trgr_AccountDuplicate
- Suffixing class names:
eg.: AccountTable_pageclassname_{suffix}.cls
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
Salesforce has introduced the concept of unlocked packages (both with or without namespaces) - check it out (https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_unlocked_pkg_intro.htm).
More recently it got possible to organize classes in folders under classes/ (and in even more fancy locations). For a decent example look here (https://github.com/trailheadapps/apex-recipes) . (Though this is a purely local thing and doesn't exist on the org itself.)