Salesforce Developer Tutorial: How and When to use Interfaces In Apex

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • In this episode we go over what interfaces are and how to use them. We also discuss the concepts of dependency inversion, dependency injection and abstraction. Interfaces are an unbelievably powerful tool that allows you to use abstraction to create more robust and flexible code. It also gives you the ability to completely decouple your UI from the actual implementation of your business logic it retrieves data from. There are few tools as powerful as interfaces in an OOP developers toolset.
    Interface Tutorial GitHub Link: github.com/Coding-With-The-Fo...
    Video Explaining Constructors: • Constructors | Java | ...
    Please consider donating to help continue to improve the content produced for Coding With The Force: www.paypal.com/donate?busines...
    Get Coding With The Force Merch Here: my-store-d20559.creator-sprin...
    Follow all of our social media here:
    Patreon: / codingwiththeforce
    Github: github.com/Coding-With-The-Force
    Facebook: / codingwiththeforce
    Twitter: / coding_force
    Instagram: / codingwiththeforce
    Salesforce development books I recommend:
    Advanced Apex Programming: amzn.to/3lXi8to
    Salesforce Lightning Platform Enterprise Architecture: amzn.to/2R0D4BQ
    Mastering Salesforce DevOps: amzn.to/3lTtTRN
    Apex Design Patterns Book: amzn.to/3DwqljP
    Good Non-SF Specific Development Books:
    Clean Code: amzn.to/35PuMDU
    Clean Architecture: amzn.to/35FYo6A
    Design Patterns: Elements of Reusable Object-Oriented Software Book: amzn.to/3LhvHBd
    -----------------------------------------------------------------------------------------------------------------------
    Table of Contents:
    0:00 - Intro
    0:20 - What we're covering in this video
    0:45 - Get Free SF Certs! Vote on New Videos! Get a Channel Membership!
    2:45 - What is an Interface?
    6:50 - Why use an Interface?
    13:35 - How to create and use an interface (Creating an Abstract Clone Component)
    14:04 - Creating the Interface
    17:05 - Creating the LWC, Controller and Generic Service Class Shells
    22:54 - Explaining Dependency Injection
    27:38 - Creating our concrete service classes that implement our interface
    39:38 - Dynamically initializing an apex class from a string
    52:35 - Outro
    DISCLAIMER: The views and ideas expressed on this TH-cam channel and blog are based on past development experiences and may not always work for your particular scenarios. The advice in these videos may also become outdated as technology advances. They should be used as examples for educational purposes only. Using any shown solutions in your own org is not advisable since they are example scenarios.

ความคิดเห็น • 20

  •  2 ปีที่แล้ว +2

    I think I am understanding the use of Interfaces in Apex, but I will need to see this video again haha. Thanks, great content.

  • @chazwatkins
    @chazwatkins 2 ปีที่แล้ว +10

    Well presented, Matt. I've shared the video with our Salesforce dev team members. Your videos are helping our team grow into solid software architecture practices. Thanks for the content.

    • @alobamify
      @alobamify 2 ปีที่แล้ว +2

      Hahaha, I did the same. The next project will be full of interfaces.

  • @philburke3652
    @philburke3652 2 ปีที่แล้ว

    Excellent demonstration of interface usage!

  • @vetealaurent3380
    @vetealaurent3380 ปีที่แล้ว

    Many thanks, well done, really like how you are able to explain 'not so easy topics to explain'

  • @karunakararaja2663
    @karunakararaja2663 2 ปีที่แล้ว

    Thanks for the video, well Explained

  • @uniquearahill6819
    @uniquearahill6819 ปีที่แล้ว

    Wow, this is very well presented.

  • @melvincorbes443
    @melvincorbes443 2 ปีที่แล้ว

    Great Explanation

  • @jpateusa77
    @jpateusa77 2 ปีที่แล้ว

    "Unbelievably cool" describes it best.

  • @tony119955
    @tony119955 2 ปีที่แล้ว +1

    Huge thanks for the great explanation! I think I understand the principles now. We will end up with more classes with object-specific (or whatever-specific) logic, instead of the huge mix of switch statements in one class.
    What might be also useful to mention is how should the common/generic functionality for those object-specific classes be implemented?
    I think we could use some generic class like 'ObjectCloneLogic', and each specific class can extend ObjectCloneLogic, right?

  • @Ron-eu7xq
    @Ron-eu7xq 2 ปีที่แล้ว

    Great content! Thanks.
    I am trying to use your playlist as a way to progress to more advance apex. Quite familiar with most of the topics covered in Apex Master Classes, so choose this video as then next best step, not sure which one I should go with next... any suggestions Matt?

    • @CodingWithTheForce
      @CodingWithTheForce  2 ปีที่แล้ว +1

      I would suggest the Separation of Concerns and Apex Common playlist or the SOLID playlist. They cover a lot of really advanced concepts in them.

  • @akram011
    @akram011 ปีที่แล้ว

    Very informative video and well explained, thank you so much! Much question is why the need for the service class, can the same result be achieved from the controller to the interface?

  • @rexieaarondavid6372
    @rexieaarondavid6372 ปีที่แล้ว

    what is that editor if you dont mind. Thanks

    • @CodingWithTheForce
      @CodingWithTheForce  ปีที่แล้ว

      It’s IntelliJ with the Illuminated Cloud 2 plugin! I have a tutorial over it and how to set it up here: th-cam.com/video/GYAQbs0Z-pc/w-d-xo.html

  • @IcyBrook
    @IcyBrook 2 ปีที่แล้ว

    I don't see a link to the constructor video?

    • @CodingWithTheForce
      @CodingWithTheForce  2 ปีที่แล้ว

      Ah yes, thanks for pointing that out! I forgot to add it to the video description. Here’s a good one: th-cam.com/video/jbcng9VhaSY/w-d-xo.html

  • @pawelb00
    @pawelb00 ปีที่แล้ว

    can interface be private?

  • @jakubdomowicz4997
    @jakubdomowicz4997 ปีที่แล้ว +1

    Hey Matt, this channel is awesome!. Question - why you take extra effort to create CloneRecords_Service if the code works without it, just by using interface class?
    @AuraEnabled
    public static void cloneRecord(Id recordId, String ClassName) {
    Type cloneClassType = type.forName(ClassName);
    CloneInterface CloneInterfaceInstance = (CloneInterface)cloneClassType.newInstance();
    ?? //CloneRecords_Service cloneRecord = new CloneRecords_Service(CloneInterfaceInstance);
    CloneInterfaceInstance.CloneRecord(recordId);
    ?? // cloneRecord.CloneRecord(recordId);
    }