Activity Forums Salesforce® Discussions What are the benefits of the “One Trigger per Object” design pattern?

  • Gourav

    Member
    April 28, 2016 at 7:53 am

    These are some basic benefits using 'One trigger per Object' design pattren

    • Reusability – with your logic in a class, you can now re-use it outside of triggers, for example in a Visualforce page, test class, batch Apex, etc. No need to copy code!
    • Simplicity – every “trigger” gets reduced to just two lines of code in the master trigger. An object oriented code base is more organized, predictable, and modular too!
    • Control your order of execution – in Apex, “the order of execution isn’t guaranteed for multiple triggers on the same object.” This pattern gives you total order control.
    • Code in style! - You’re going to look like an Apex master using this pattern whether or not you take advantage of any of the benefits above. Plus, it’s a common interview question!
  • Shubham

    Member
    April 28, 2016 at 10:06 am

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos