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 ?
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)
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)
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.
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.
Senior Technical Architect | 16x certified | Application Architect | Devops certified | FSC Accredited
4 年last image ??