Skip to content

Instantly share code, notes, and snippets.

@kenandersen
Last active August 29, 2015 14:08
Show Gist options
  • Save kenandersen/2d2f719a128184c2d1e0 to your computer and use it in GitHub Desktop.
Save kenandersen/2d2f719a128184c2d1e0 to your computer and use it in GitHub Desktop.
A reference describing access modifiers in Salesforce's Apex language

Access Modifiers in Apex for Salesforce.md

####Header Apex has four different access modifiers when you define your classes and triggers and the subsequent methods and variables.

  1. Private
    • The default and most used access modifier. A method or variable with the modifier is only accessable within the Apex class (or trigger) in which its defined.
  2. Protected
    • This one is a little more open than Private. A method or variable with the Protected modifier is only accessable to any inner classes of the defining Apex and to classes that extend the defining Apex class.
  3. Public
    • One step up from Protected! (see the pattern?) Methods or variables with the Public modifier can be used by any Apex in the application or namespace (basically by within anything in your Salesforce org).
  4. Global
    • The most open of them all! A method or variable with the Gobal modifier can be referenced outside the application or even your Salesforce org via the SOAP API. If you decalre a method or variable as global, the class that it's contained within must be declared Global as well.

######For more information reference the offical Salesforce/Apex documentation.

Follow me on Twitter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment