Spaces for short methods #9

Closed
opened 2017-12-11 11:38:47 +00:00 by regar42 · 1 comment
Collaborator

For methods such as :
public boolean isWalkable() {
return false;
}

Do we want blank lines to space our code, such as :
public boolean isWalkable() {

     return false;

 }

or even :
public boolean isWalkable() {

     return false;
 }

or maybe no blank line ?
I woulnd't mind putting no blank line.
Some methods are implemented with the first method, some with the second, and some with the no blank line method. It should be harmonized in normalizeSpaces.

For methods such as : public boolean isWalkable() { return false; } Do we want blank lines to space our code, such as : public boolean isWalkable() { return false; } or even : public boolean isWalkable() { return false; } or maybe no blank line ? I woulnd't mind putting no blank line. Some methods are implemented with the first method, some with the second, and some with the no blank line method. It should be harmonized in normalizeSpaces.
regar42 added the question label 2017-12-11 11:38:47 +00:00
antograb was assigned by regar42 2017-12-11 11:52:26 +00:00
Owner

For methods with only one instruction, I'd choose this :
public boolean isWalkable() {
return false;
}
It's the most elegant as it is very small.

For longer methods, I'd choose this :
public boolean isWalkable() {

    Instruction 1;
    Instruction 2;
    return false;
}
For methods with only one instruction, I'd choose this : public boolean isWalkable() { return false; } It's the most elegant as it is very small. For longer methods, I'd choose this : public boolean isWalkable() { Instruction 1; Instruction 2; return false; }
Sign in to join this conversation.
2 Participants
Notifications
Due Date
-
Dependencies

No dependencies set.

Reference: antograb/TpMazeJava#9