Do you think the following fragment of code (for-loop + continue)
for (Identity fileIdentity : fileIdentities) {
totalFileCount++;
if (!forceTheStatus(params, fileIdentity))
continue;
updatedFileCount++;
if (!params.shouldUpdateLinkedEntity())
continue;
Optional<Identity> batchIdentity = getLinkedBatchIdentity(fileIdentity);
if (!batchIdentity.isPresent())
continue;
totalBatchCount++;
if (!getRemittanceProcessor().forceTheStatus(params, batchIdentity.get()))
continue;
updatedBatchCount++;
}
is better than this other (for-loop + Arrow Anti Pattern)? And why?
for (Identity fileIdentity : fileIdentities) {
totalFileCount++;
if (forceTheStatus(params, fileIdentity)) {
updatedFileCount++;
if (params.shouldUpdateLinkedEntity()) {
Optional<Identity> batchIdentity = getLinkedBatchIdentity(fileIdentity);
if (batchIdentity.isPresent()) {
totalBatchCount++;
if (getRemittanceProcessor().forceTheStatus(params, batchIdentity.get()))
updatedBatchCount++;
}
}
}
}
To me the solution with continue looks harder to understand, but on the other hand we have an anti-pattern :(
Aucun commentaire:
Enregistrer un commentaire