[bisq-network/style] Do not use `else if` and `else` clauses where `return` statements make them redundant (#12)

Chris Beams notifications at github.com
Wed Jun 6 09:20:49 UTC 2018


For example, in the following code, the `else if` and `else` clauses are redundant:

```java
if (someCondition) {
    return X;
} else if (otherCondition) {
    return Y;
} else {
    return Z;
}
```

This code can and should be simplified to read as follows:

```java
if (someCondition)
    return X;

if (otherCondition)
    return Y;

return Z;
```

Whether or not braces are used for single-line conditionals is a matter for a different style rule, but in any case, the second code block is easier to read, uses fewer conditional constructs, and makes it all the more obvious that returning "Z" is the fallback / default case if no preceding conditionals are matched.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/style/issues/12
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20180606/2245ad6e/attachment.html>


More information about the bisq-github mailing list