Data Types, Class, Access Modifiers in Salesforce

Access modifiers in Salesforce are used to define the visibility and accessibility of classes, methods, variables, and other components within an organization.

Table of Contents

Day1

If you have missed the previous session here is the link – https://www.pantherschools.com/introduction-to-oops-using-salesforce

Primitive data type in Salesforce

They are simple, basic data types that are built into the Salesforce platform and cannot be broken down into smaller components.

  • Integer: A whole number without a decimal point.
  • Double: A number with a decimal point or a fractional component.
  • Boolean: A data type that can have one of two possible values – true or false.
  • Date: A data type that represents a date.
  • Time: A data type that represents a specific time.
  • DateTime: A data type that represents a specific date and time.
  • String: A sequence of characters that can include letters, numbers, and symbols.
  • ID: A unique identifier for an object in Salesforce. ( 18, 15 ) 001GHJHGHE87734
  • Decimal: A number with a decimal point, with up to 18 digits

Non-primitive data type in Salesforce

The non-primitive data types in Salesforce include:

  • Object
    • Variables
      • Primitive
        • Name
        • Age
      • Non Primitive
        • Person Object
        • Animal Object
  • Map
  • List
  • Set
  • Apex Class
    • Variables
    • Methods

Assignment

Create variables for all the Primitive Data Types and print those with dummy values.

Classes in Salesforce

A class is nothing but it is a collection of objects and carries all the properties of an object.

We can also say that the class is the blueprint for creating the Objects.

A class can contains the followings –

  • Classes
    • Access Modifiers
    • Variable
    • Methods
    • Constructors

Access Modifiers in Salesforce

Access modifiers in Salesforce are used to define the visibility and accessibility of classes, methods, variables, and other components within an organization.

There are three types of access modifiers in Salesforce:

  1. Public: Components with the public access modifier are visible and accessible to all classes and triggers in an organization. This means that any class or trigger in the organization can access and use these components.
  2. Private: Components with the private access modifier are only visible and accessible within the same class in which they are defined. This means that no other class or trigger in the organization can access or use these components.
  3. Protected: Components with the protected access modifier are visible and accessible within the same class and any subclasses that extend the original class. This means that any class that inherits from the original class can access and use these components.
    1. Class A (Parent)
      1. Protected Variables
    2. Class B (Child ) extend Class A (Variable & Methods)
      1. Access Protected Variables
  4. Global
    1. Managed Package ( Application ) ~= Applications in Google/Apple Store
      1. Class
        1. Variable
        2. Method

Variables(States) in Salesforce

Variables in Salesforce are used to store and manipulate data within Apex code.


					
				

Hands-On Code


					
				

Assignment

Play around with Class & Instance Variable along with Access Modifiers

Full Video

Resources

Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading