Don't write "static" methods :D
PLEASE don't make your methods static πŸ˜…
I am not sure why, but so many people make methods static.
Static = shared between all instances of a class.
For example:
public class Person {
public static String planet = 'Earth';
}
That makes sense. Any time you create a person object, they will have a shared variable called planet.
But...
Static is something extra. You only add it in two cases:
1) You are using some annotation (e.g. @AuraEnabled) and it requires you to make it static.
2) You have some good reasons and it fits logically. (it's rather rarer)
If you can't explain to yourself why the method has to be static and can't be just a normal method you should not use static methods.
Otherwise, you can end up in situations like the screenshot, where you have a private method that is static. Which is bad, because it defeats the whole purpose of either "private" or "static".
Let me know if you guys have any questions :)
7
6 comments
Igor Kudryk
5
Don't write "static" methods :D
Integration Mastery Cohort
skool.com/integration-mastery-cohort-4062
Learn Integrations in 8 weeks.
Leaderboard (30-day)
Powered by