...
<to be described : possible link we can use: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request>
PR Coding Best Practices
When submitting a PR keep in mind these principles:
- Try to be concise and right to the point. Just modify whatever needs to be modified to solve the issue at hand.
- If your code is complex:
- submit a unit test as well.
- add comments for the most complex parts.
- Try to keep the code readable, maintainable, easy to debug and performant.
Streaming API considerations
Avoid using unnecessary streaming API constructs. For instance, this code:
Code Block | ||
---|---|---|
| ||
for (Transaction commit : SPIAccessor.DEFAULT.getCommits(bag)) {
SPIAccessor.DEFAULT.check(commit, true);
} |
Could be transformed to the Streaming API equivalent:
Code Block | ||
---|---|---|
| ||
SPIAccessor.DEFAULT.getCommits(bag).forEach((commit) -> SPIAccessor.DEFAULT.check(commit, true)); |
But the resulting code will be slower and more difficult to debug, so it does not add value to the source code.
When using the Streaming API always try to be readable and make the code easy to debug.
Keep explicity typing
Try not to remove typing when using generics with the diamond operator. So, for instance, you could replace
Code Block | ||
---|---|---|
| ||
ArrayList<JCVariableDecl> fieldGroup = null;
// lots of lines here...
fieldGroup = new ArrayList<JCVariableDecl>(); |
With
Code Block | ||
---|---|---|
| ||
ArrayList<JCVariableDecl> fieldGroup = null;
// lots of lines here...
fieldGroup = new ArrayList<>(); |
This is, you could use the diamond operator in the assignment, but this will result in a less readable code. Try to keep explicit typing visible as much as possible, pondering always readability over syntax sugar.