Skip to main content

Software systems develop dynamically over long periods of time.

The current state often deviates far from the originally planned and even more so from the architecture, structure and quality desirable today.

Refactoring and other corrections are therefore always necessary to improve existing software and restore an acceptable level of quality. itestra carries out HealthChecks and software optimization and renovation projects for numerous companies, making existing software better.

Show us your understanding of quality and rate the code described below.

Can you recognize anti-patterns here?

How much LoC do you need to implement a perfect solution to the problem?

public static int customUtilsFunction(final CharSequence cs, final char... sc) {
  if (ArrayUtils.isEmpty(sc)) {
  return -1;
  }
  final int csL = cs.length();
  final int scL = sc.length;
  outer:
  for (int i = 0; i < csL; i++) {
  final char ch = cs.charAt(i);
  for (int j = 0; j < scL; j++) {
  if (sc[j] == ch) {
  if (i < csL - 1 && j < scL - 1 && Character.isHighSurrogate(ch)) {
  if (sc[j + 1] == cs.charAt(i + 1)) {
  continue outer;
  }
  } else {
  continue outer;
  }
  }
  }
  return i;
  }
  return -1;
}

My solution

  • This field is for validation purposes and should be left unchanged.
svg+xml;charset=utf itestra

Leave a Reply