Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

<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:

  1. Try to be concise and right to the point. Just modify whatever needs to be modified to solve the issue at hand.
  2. If your code is complex:
    1.  submit a unit test as well.
    2.  add comments for the most complex parts.
  3. 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
languagejava
for (Transaction commit : SPIAccessor.DEFAULT.getCommits(bag)) {
	SPIAccessor.DEFAULT.check(commit, true);
}

Could be transformed to the Streaming API equivalent:

Code Block
languagejava
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
languagejava
ArrayList<JCVariableDecl> fieldGroup = null;
// lots of lines here...
fieldGroup = new ArrayList<JCVariableDecl>();

With

Code Block
languagejava
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.