Outcome is same but journey experience matters !

“Success is a journey, not a destination. The doing is often more important than the outcome.”

I got so much inspired with this quote that during code review process i found one thing as below and then i tried to related this piece of code with this Quote.

List<Account> allAccountList = [Select Id from Account limit 5000]; 
Set<Id> acctIds = new Set<Id>(); 
for(Account act : allAccountList){ 
 acctIds.add(act.id); 
	

As a newbie in Salesforce ecosystem, Could you find any issue in above code snippet ?

As a mid level experience developer, Could you find any issue in above code snippet ?

No alt text provided for this image

Ok, No worries if you wouldn't able to find any problem in code snippet, But i'm sure you have found the problem in above image.

But anyways let me give you one more hint and share apex code execution time for above code snippet. (With help of Console debug tool)

No alt text provided for this image


Now let me share new code snippet which does the same work or you can say output in same as previous code snippet.

Map<id, Account> actMap = new Map<id, Account>([Select Id from Account limit 5000]); 
List<account> allAccountList = actMap.values() ;  
Set<id> acctIds = actMap.keySet() ;

Now lets see how much time it took to execute this Apex code snippet. (With help of Console debug tool)

No alt text provided for this image

Have you noticed time difference between both the code snippet ? Just imagine small code snippet which does the same work as other but how the time difference (Time complexity ) comes in picture the way we write code.

No alt text provided for this image

But every small step in the wrong direction also counts (In terms of Apex CPU limit). Hence please take care of the code which you write in your day to day life at your job.

Not every developer can leave footprints behind them but every Salesforce developer can make sure they won't leave Apex code which may cause problem to upcoming developer where they struggle to rectify your code and try to make control of apex transaction within Apex CPU limit.

Hamari jindgi ka ek hi maksad hain !!!! Hum sabko maja dena chate hain !! Aisa Apex code likho ki maja aa jaye dekhne wale ko use karne wale ko.

No alt text provided for this image





Himanshu Bhatt

Senior Technical Architect | 16x certified | Application Architect | Devops certified | FSC Accredited

4 年

last image ??

要查看或添加评论,请登录

Viren Sa的更多文章

  • Sometimes Age and Certification count comes alone !

    Sometimes Age and Certification count comes alone !

    Here are few things which I should ask to myself ? 1. Do I judge maturity level of person with his/her Age ? 2.

    1 条评论
  • WORA : Write Once Use Everywhere

    WORA : Write Once Use Everywhere

    Hello Bhaiyo and Bhano, Ladies and Gentleman, Boys and Girls. I hope you have heard about this phrase Necessity is the…

    1 条评论
  • ApexGuru OR ApexLearner Quiz 2

    ApexGuru OR ApexLearner Quiz 2

    Unpredictability means what it means. I don't know how you define it.

    3 条评论
  • ApexGuru or ApexLearner Quiz 1

    ApexGuru or ApexLearner Quiz 1

    Can you please help us to find out what will be the correct output on console log for below code snippet as for us this…

    7 条评论
  • What will be the output ?

    What will be the output ?

    Assume we have one Trigger defined on Case Object in Salesforce. Trigger code will look like below.

    3 条评论
  • How much difficult to learn Salesforce ( Admin Role)

    How much difficult to learn Salesforce ( Admin Role)

    **NO TECHNICAL BACKGROUND REQUIRES TO LEARN SALESFORCE ADMIN :) Before to understand how much difficult to learn…

    4 条评论
  • ForceFunda has been launched

    ForceFunda has been launched

    Key to unlock excellence in Salesforce for a beginner as a duck takes to water. Introduction video is here.

社区洞察

其他会员也浏览了