Mistři v programování na #hovnokod

Java #4717

Code review comment: Digits here repeat, if you create constant for them and give them self-explanatory name, it would make code more readable and easier to modify, and less prone to errors when refactoring Toto byla uprava

//before
 if (birthDate.length() >= 6) {
                     builder.append(dash);
                     builder.append(birthDate.substring(4, 6));
 }

//after
final int birthDateStrLen = birthDate.length();
  if (birthDateStrLen >= 8) {
             builder.append(dash);
             builder.append(birthDate.substring(6, 8));
   }

Anonymous,