I would be really grateful if anybody could help me clarify, where to deploy business logic.
I'm aware of the following possibilities:
Write the main parts of the business logic in Apex
Apex provides many utility functions and missing functionality could be integrated through external web services. In addition, written code can be deployed as a web service.
- DRY and KISS, in particular: Code can be easily used in Salesforce and through external services.
- Less fragmented deployment structure.
- Focus on Salesforce as primary system.
- High dependency on the Salesforce platform (lock-in).
- Limitations due to Salesforce quotas (@future method).
Write the business logic in PHP
Through the Salesforce PHP API, business logic can be deployed on a web server.
- Less limitations (@future method quota is more restrictive than API request quota)!? Not shure on this point.
- Less Apex knowledge required.
- Lower risk for lock-in.
- Solution is less sexy.
- Maybe duplicate code.
- Shared business logic (used on several platforms) causes messy information flow.
Are there more advantages / disadvantages to consider? Are there any best practices?
I would like to illustrate my very abstract question with an example.
Imagine you've got an provider for phone tracking and you're able to create new phone numbers through an API and let's assume furthermore there is more effort needed than calling this API (more complex function). In my opinion this is business logic and I would like to refer to this as createTrackableNumber.
The function (or method) createTrackableNumber asks the provider for a new phone number and saves the response to an Salesforce Account.
Moreover you want to provide the createTrackableNumber functionality to the salesperson (usable within Salesforce) and simultaneously through a web based tool to the customer.
In this use case you can't use "point and click". Would you write createTrackableNumber in Apex and expose it as a web service (for example with @RestResource) or would you write it in PHP and use within Salesforce and the web based tool?
Is one possibility maybe more "quota friendly" than the other? Any other considerations to make?
Kind Regards, Florian Kalisch