Access Modifiers - Global vs Public vs Private | Chapter 21 | Salesforce Developer Masterclass

Поділитися
Вставка
  • Опубліковано 6 жов 2024
  • Welcome to another crucial episode of the Salesforce Developer Masterclass, titled "Access Modifiers - global vs public vs private." This video is essential for Salesforce developers aiming to understand and utilize access modifiers in Apex to control the visibility and accessibility of their code effectively.
    Access modifiers in Apex define the scope of access for classes, methods, and variables. Understanding how to use them correctly is vital for writing secure, maintainable, and efficient code. In this episode, we will break down the three primary access modifiers in Apex: global, public, and private.
    Global: We’ll start with the global access modifier, which allows the widest level of access. A global class or method is accessible across all Apex code, both within your namespace and outside, including managed packages. We’ll discuss scenarios where using global is appropriate, such as when creating APIs or services intended for broad reuse.
    Public: Next, we’ll cover the public access modifier. Public classes and methods are accessible within your application or namespace but not outside of it. This is the default access level you will use when developing most internal application logic. We’ll explain when and why to use public, ensuring your code is accessible where needed while maintaining encapsulation.
    Private: Lastly, we’ll delve into the private access modifier, which restricts access to the defining class itself. This modifier is crucial for encapsulating code and protecting the internal state of objects from unintended interference. We’ll provide practical examples to illustrate how private can be used to maintain the integrity and security of your classes and methods.
    Throughout the video, we’ll provide practical examples and best practices for using each access modifier, helping you understand the implications of your choices and how to implement them effectively in your Salesforce development projects.
    By the end of this episode, you will have a comprehensive understanding of access modifiers in Apex and how to use them to control the visibility of your code components, ensuring your applications are robust, secure, and well-structured.
    If you want to continue learning Salesforce (for free), Subscribe Salesforce Makes Sense here
    / @salesforcemakessense
    To ensure a smooth learning experience,
    I have curated playlists that will help you prepare for interviews, train on specific domains and boost your Salesforce journey.
    30 Scenario Based Questions:
    • 30 Salesforce Scenario...
    The Complete Administrator Course
    • Learn Salesforce Admin...
    Learn Salesforce in Bytes - Short videos on Salesforce features
    • Salesforce Bytes
    Learn Salesforce With Me - Topic based Explanatory Videos
    • Learn Salesforce with Me
    65 Salesforce Interview Questions:
    • 65 Interview Questions...
    100 Salesforce Interview Questions:
    • 100 Salesforce Intervi...
    If you would like to acknowledge my efforts and want me to continue training and mentoring, you can support me here.
    www.buymeacoff...
    For any kind of questions, training & mentorship, queries & concerns,
    Feel free to drop a mail at
    salesforcemakessense@gmail.com
    That’s all from this video. See you in the next video. Till then, breathe long and keep learning :)

КОМЕНТАРІ • 13

  • @RohitGupta-vv8wt
    @RohitGupta-vv8wt 4 місяці тому +2

    Nice explanation and best part is simplicity

  • @pishan155
    @pishan155 2 місяці тому +1

    Well Explained sir

  • @sreenivaspakalapati4759
    @sreenivaspakalapati4759 2 місяці тому +1

    Able to create ‘AvailableToAll’ class with global Access Modifier
    Able to create ‘AvailableToSome’ class with public Access Modifier
    During the creation of ‘JustAvailable’, system throwed me below error: Top-level type must have public or global visibility
    And after providing public or global. No errors were encountered
    Thanks for your Contribution.

    • @salesforcemakessense
      @salesforcemakessense  2 місяці тому

      @@sreenivaspakalapati4759 perfect and as expected 🙂

    • @mohdgous9631
      @mohdgous9631 Місяць тому +1

      Which means we surely require to put one of the access modifiers . We cannot procede into a class without putting one right ?

    • @salesforcemakessense
      @salesforcemakessense  Місяць тому

      @@mohdgous9631 Yes!

  • @sumitB-h8t
    @sumitB-h8t 4 місяці тому +2

    For the Third JustAvailable class, I am getting an error while saving it. Error:- Top level type must have public or global visibility.

    • @salesforcemakessense
      @salesforcemakessense  4 місяці тому +2

      Yes, that's expected, check the next video where I explain the same :)

  • @ravigrover1923
    @ravigrover1923 4 місяці тому +1

    It shows this: `Inner types are not allowed to have inner types`
    global class AvailableToAll {
    public class AvailableToSome{
    class JustAvailable{

    }
    }
    }

  • @oscarvasquez7029
    @oscarvasquez7029 2 місяці тому +2

    Hello sir,
    Hope you’re doing well.
    I’d like to thank you n bow down to u 🙇‍♂️ for taking time out to give back your knowledge to community in this selfish world. Just by this you-tube platform your changing our lives and make us a part of the Salesforce ecosystem. 🫂🙇‍♂️🙏

    • @salesforcemakessense
      @salesforcemakessense  2 місяці тому +2

      Hi Oscar, that's really kind of you to say that. SO happy to hear the content is helping :)