2

Most of the pages in our application have been built using HTML5/CSS/Bootstrap/Javascript Remoting/JQuery/AngularJS. Their controllers have most of the methods with @RemoteAction and other static methods called from remote methods. What are some good practices for such controllers.

3

Few Best Practices I can remember:

  1. Avoid calling remote function in for loop.
  2. Keep payload size minimum in controller
  3. Don't use global/public variables in static method or any approach like this. Keep everything in method.
  4. Sometimes same thing needs to be done again and again for each remoting method in controller. Create a common utility for it.
  5. Remoting count agains API calls, so this limit should be considered.
  6. Users can lose their network connection in mid-transaction, or alter the way that your page’s JavaScript executes with Firebug and other tools. Always do server/controller side checks before returning results or perform action.
  7. Remoting can upsert/insert/update in parallel on same object. Design your method to avoid Record Lock situation.
  8. Use wrapper classes instead of List/Map to return result. This makes the code readable and manageable to your next dev and yourself.
| improve this answer | |
  • I'm fairly certain that remoting calls do not count against the API limit anymore. – JCD Aug 24 '15 at 13:33
  • @JCD you may be correct but practically I have seen these calls increasing API count. Lets wait to confirm by other. – Ashwani Aug 24 '15 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.