I have seen code that looks like this
Although there is nothing wrong in this, conventions suggest that this be written in a readable way like
but lets say we have some more statements like this
I would consider it will be more readable to put it as
public void static fn(boolean someCondition){
if(someCondition) {
return error();
}
return success();
}Although there is nothing wrong in this, conventions suggest that this be written in a readable way like
return someCondition ? error() : success();
but lets say we have some more statements like this
public void static fn(boolean someCondition){
if(someCondition) {
statement1;
statement2;
return error();
}
statement2;
statement4;
return success();
}I would consider it will be more readable to put it as
public void static fn(boolean someCondition){
if(someCondition) {
statement1;
statement2;
return error();
}else{
statement2;
statement4;
return success();
}
}