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

Make variable names more descriptive #13

Open
neugierige opened this issue Dec 8, 2016 · 3 comments
Open

Make variable names more descriptive #13

neugierige opened this issue Dec 8, 2016 · 3 comments

Comments

@neugierige
Copy link

Because resolve and reject are the variable names use in the Promises documentation, some developers are interpreting these terms to be key terms with designated meaning in JS. It would be helpful to rename them to something more explicit to make clear that these are other functions that we are writing/have written.

I would propose runResolve and runReject, or perhaps doThisIfResolved and doThisIfRejected

@gaand
Copy link

gaand commented Dec 8, 2016

I'm am strongly opposed to this suggestion based on the principle of least surprise.

If we start with the suggested names and explain why it's better to name things as others expect, that might be okay.

@neugierige
Copy link
Author

Data point from 12/14/16: developer question, "are resolve and reject [variables] a part of a Promise"? I verified with the student; he indeed did not understand that they were variables, even though we have been using Promises for almost a week.

@jrhorn424
Copy link

Because resolve and reject are the variable names use in the Promises documentation, some developers are interpreting these terms to be key terms with designated meaning in JS.

They have a strong conventional meaning in JS. They're directly analogous to return and throw, respectively. IMO, they should be treated as "keywords" even though they are functions.

they were variables

In this context, I'm not sure saying they are "variables" is particularly helpful. Everything with a name is variable (this is an overgeneralization to serve my point); I think it's better to get developers thinking about what kinds of things lie behind pointers. In this case, resolve and reject are functions that do the (complex) work of coordinating a data pipeline in an asynchronous chain.

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

3 participants