Is there any way in Salesforce to group apex classes under a package or namespace? Can we use managed package for internal organization purpose?
As per your question, a namespace can be said to be the prefixes used to differentiate custom object and field names in. managed Force.com AppExchange packages.
If you have unit tests in at least one Apex class, click Run All Tests to run all the unit tests in your organization. Click Compile all classes to compile all the Apex classes in your organization.
This is a limitation in the force.com stack that makes medium-large size projects painful, if not impractical. Using managed packages in order to get a package prefix doesn't really solve any problems, so it's not really worth the trouble.
I usually try to organize a project into one flat level of namespaces. In lieu of actual namespaces, I'll give each would-be-namespace a 3-5 character name, to be used as a prefix. Any class that belongs in the "namespace" gets prefixed. E.g., if I need a payroll
namespace, I'd use a PYRL
prefix. A class called PaycheckCalculator
becomes PYRL_PaycheckCalculator
.
The practical advantage of this type of convention is it helps prevent name clashes and classes are grouped by their "namespace" when viewed in a sorted list, such as in an IDE, or Setup > Develop > Apex Classes
Unfortunately, several basic OO principles are still fundamentally broken. Probably the most important one is every class forms an implicit dependency on every other class it has visibility to, which is all of them.
I'd love to hear how others have worked around this limitation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With