Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add opinion on @future methods #3

Open
YodaDaCoda opened this issue Jun 15, 2021 · 2 comments
Open

RFC: Add opinion on @future methods #3

YodaDaCoda opened this issue Jun 15, 2021 · 2 comments
Assignees

Comments

@YodaDaCoda
Copy link
Member

YodaDaCoda commented Jun 15, 2021

@future methods are great, but sometimes you want to call the method synchronously. Propose a convention whereby all future methods do nothing more than call another non-future method. Naming convention for future/non-future method pairs TBC.

e.g.

BAD

@future
public static void myMethod(Account myAccount) {
    // do a whole bunch of things with myAccount
}

GOOD

@future
public static void myMethod_future(Account myAccount) {
    myMethod(myAccount);
}

public static void myMethod(Account myAccount) {
    // do a whole bunch of things with myAccount
}
@YodaDaCoda
Copy link
Member Author

Personally, I like myMethod/myMethod_future but PMD will complain unless we adjust the ruleset.

@YodaDaCoda YodaDaCoda self-assigned this Jun 15, 2021
@ehsankorhani
Copy link

ehsankorhani commented Jun 16, 2021

GOOD

@future
public static void myMethodAsync(List<ID> recordIds) {
    // Query the sObject with the incoming parameter.
    myMethod(myAccount);
}

public static void myMethod(Account myAccount) {
    // do a whole bunch of things with myAccount
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants