Sharing Setting default for new apex classes

Issue #605 resolved
Former user created an issue

The default template for Apex class is "with sharing". IMHO there should be no sharing setting per default.

Apex code is executed "without sharing" per default. If I create a new Apex class with Developer Console its created without an explicit sharing setting as well.

Comments (2)

  1. Scott Wells repo owner

    John, the reason that the default template uses with sharing is that is the prescribed best practice from Salesforce for writing secure code. In fact, for those taking code through security review, you have the justify any class that doesn't explicitly use with sharing since otherwise the sharing model is either ambiguous (no specification) or escalated (without sharing). If in your implementation the standard practice is to use another sharing model, the file templates are editable and can be customized for your needs.

  2. Scott Wells repo owner

    If you do find that you're unable to customize the file templates to match your practices, please reopen with details.

  3. Log in to comment