Salesforce Apex Master Class (Ep. 30) - Collection Iteration Best Practices

Поділитися
Вставка
  • Опубліковано 27 лип 2024
  • In this episode we go over some best practices when iterating over collections in Apex to help ensure you don't run into limits!
    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
    Good Non-SF Specific Development Books:
    Clean Code: amzn.to/35PuMDU
    Clean Architecture: amzn.to/35FYo6A
    -----------------------------------------------------------------------------------------------------------------------
    Table of Contents:
    0:00 - Intro
    2:35 - Why you should always bulkify DML Statements
    8:11 - Why you should never use SOQL when iterating over collections
    11:22 - Why you should try to use Maps instead of nested for loops
    15:16 - Outro
    DISCLAIMER: The views and ideas expressed on this UA-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.
    #salesforce #salesforcedeveloper #salesforceadmin

КОМЕНТАРІ • 7

  • @gavin0729
    @gavin0729 6 місяців тому

    best salesforce class ever!

  • @SliceOfSampai
    @SliceOfSampai Рік тому +1

    Just finished your entire Salesforce Apex Master Class video series. Thanks a bunch for your dedication!

  • @pedroprada1
    @pedroprada1 Рік тому +1

    Happy New Year Matt, Thank you for continuing to add to this playlist....

  • @cristiaan3003
    @cristiaan3003 Рік тому

    Thank you for sharing this videos with all !!

  • @chithraprakash8392
    @chithraprakash8392 Рік тому

    Thank you for sharing this great video. Can you please upload videos on each of the concepts you mentioned in this video, nested for loopand querying inside a for loop(what should I use in this scenarios). Very useful video.

  • @extremeweirdness1528
    @extremeweirdness1528 Рік тому +1

    I had a question on the for loop part. You said to avoid nested for loops right. I have a similar opinion though but I could never really test it.
    Suppose you have a trigger handler for account and there are 50 methods that do something on those accounts. We usually pass in the Account list and iterate over each one in a for loop.
    Instead what if we cut down those 50 methods to take in a single Account instead of a List of accounts. Now we would only need two for loops. We can have one big for loop that passes a single Account in each of those 50 methods.
    Now this is not going to make any improvements for one Account but what if you have 50 Accounts. You would have had to iterate over 2500 times instead of 100 thats a 25 x improvement by not bulkifying your methods and just having one big for loop.

    • @anthonybarrow3396
      @anthonybarrow3396 Рік тому

      Not sure I understand your theory but do remember the SF limit is on the number of SOQL and DML statements and not the number of iterations. By not bulkifying you will hit SF governor limits in dataload scenarios