nus-cs2113-AY2324S2 / forum

2 stars 0 forks source link

Git and Java Conventions #8

Open annoy-o-mus opened 7 months ago

annoy-o-mus commented 7 months ago

The first question is regarding the git commit message subject I want to follow the commit message subject styling Here, in addition to those mentioned in the SE-Education.

In it I add a commit type to each commit, and then capitalising the first letter of the description that follows. Which essentially transform commit messages from

Add input handling Update installation guide Shift processing to Processing class

to

feat: Add input handling docs: Update installation guide refactor: Shift processing to Processing class

I would like to ask if this is allowed or is it not advised.

The second question is regarding Java styling conventions. Should there be a space before the left brace of the array initializer, i.e

int[] X = new int[] {1, 3, 5, 6, 7, 87, 1213, 2};
int[] empty = new int[] {};

instead of

int[] X = new int[]{1, 3, 5, 6, 7, 87, 1213, 2};
int[] empty = new int[]{};
adamzzq commented 7 months ago

... the array initializer, i.e.

int[] X = new int[] {1, 3, 5, 6, 7, 87, 1213, 2};
int[] empty = new int[] {};

Sorry I just wanted to tag along with your question as I have a closely related one. Java seems to allow a shorter syntax for array initialization: int[] X = {1, 2, 3};, which I feel is more readable than the one with new int[]. I wonder which one is preferred in this course?

okkhoy commented 7 months ago

Git convention: you are allowed to use prefixes in the commit message as per the example stated.

Java: Should there be a space before the left brace of the array initializer ... Yes. For things not explicitly mentioned in the coding standards, we will follow the Google style guide. Though not explicitly mentioned, you can see the spacing is the same as what is asked.

For array initialization, you can use either method. There are no restrictions.

okkhoy commented 7 months ago

reopening as PSA.