Ich habe einen Block von Code, der ein Problem hat, das die zyklomatische Komplexität von reduziert. Wegen der vielen Bedingungen, die zusammenpassen müssen, bin ich mir nicht sicher, ob es am besten ist, sie weiter zu reduzieren. Erschwerend kommt hinzu, dass in 2 Fällen ein neues Objekt erstellt wird, nicht aber im dritten (es ruft eine andere Methode auf). Dies ist der Pseudo-Code:Cyclomatic Komplexitätsreduktion
if (!cond3 && !cond1 && cond2 && cond4) {
// actions to perform
calculateValues();
return result;
} else if (!cond1 && cond2 && cond3) {
// actions to perform
Object result = new Result();
return result;
} else if (!cond4 && cond3 && cond1 && cond5) {
// actions to perform
Object result = new Result();
return result;
} else {
// throw error because inputs are invalid
}
Sieht gut für mich aus. –
@LouisWasserman, ist das Sarkasmus? – jaco0646
@ jaco0646, nein, ist es nicht. –