Use a solution that will cover all cases instead of fixing only specific instances of the problem.

Evidently the following code was added to fix a bug where searches for “McDonald” did not find any “MacDonald” users:

if (surname.equals(“McDonald”)) surname = “MacDonald”;

Unfortunately this did not fix all of the other searches, such as for McConnell or McLeod!

A better solution would have been as follows:

if (surname.startsWith(“Mc”))
    surname = “Mac” + surname.substring(2,surname.length());
blog comments powered by Disqus