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.
Possible advantages:
- 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.
Possible disadvantages:
- 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.
Possible advantages:
- 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.
Possible disadvantages:
- Solution is less sexy.
- Maybe duplicate code.
- Shared business logic (used on several platforms) causes messy information flow.
Write the business logic in JavaScript
Just to be complete... the JavaScript API could be used, although I think that the business logic should reside on the server side.
Are there more advantages / disadvantages to consider? Are there any best practices?
Edit:
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