Closed EvitanRelta closed 1 year ago
On a general note, it is advisable to follow the coding standard strictly, without making further stylistic choices. That way, the result will be the same no matter which developer is writing the code. Otherwise we would need to discuss and decide the line wrapping choice every time there is a need to wrap a line.
Hi OP, I would like to share a link on Oracle Convention in addition to the Google Java Style Guide provided in the coding standard guide. Hope this will be helpful!
Also, I personally would prefer to follow the coding standard which led to me choosing this option:
assertEquals(TaskDeadlineTest.getTestTask(),
TaskDeadlineTest.getTestTask());
Reason being that Egyption Style braces may be very confusing if there is a really long method with nested braces involved. An example (might not be the best) I can think of would be:
# option A
new A(
veryLongParam1,
new B(
veryLongParam2,
veryLongParam3,
veryLongParam4))
vs
# option B
new A(veryLongParam1,
new B(veryLongParam2,
veryLongParam3,
veryLongParam4))
Option B seems clearer and more intuitive to me as compared to option A. Would like to know what OP thinks about this though!
How should the below code be formatted?
Specifically, how much indent, whether the first element should be on the same line, and where should the closing bracket/brace be.
Based on the coding standard, i assume it should be:
"D"
) on the same lineBut how about egyptian-styled brackets/braces:
Additionally, how bout the below code? Which one is acceptable?