The Fearless Leader at Randy's company had heard wonderful things about Service-Oriented Architecture, and knew that's exactly what their in-house applications needed in order for the company to remain competitive. Obviously, in-house developers couldn't possibly have the skill or knowledge to develop such things, so the Fearless Leader brought in consultants to develop the service suite.
One of the web services that the consultants developed was the Global Customer Search. Essentially, it searched for customers through a handful of different systems throughout the entire enterprise. "According to the documentation," Randy wrote, "the GES uses an advanced scoring algorithms to determine how close of a match a record may be when someone searches using the web service. As you can see from the code, the consultants started off on the right foot... and then decided to give up at the end. "
public float calculateWeight( MemberRequest srvRequest, int probeility) { int minScore = 0; if (srvRequest.getZipCode() != null) { if (srvRequest.getLastName() != null && srvRequest.getLastName() != null) minScore = (float) (minScore + 6.1); else if (srvRequest.getLastName() != null) minScore = (float) (minScore + 5.7); else minScore = (float) (minScore + 2); } else minScore = (float) (minScore + 2); if (srvRequest.getDateOfBirth() != null) minScore = (float) (minScore + 4.3); if (srvRequest.getID1() != null) minScore = (float) (minScore + 5.9); if (srvRequest.getID2() != null) minScore = (float) (minScore + 3.2); if (srvRequest.getPhoneNumber() != null) minScore = (float) (minScore + 3.8); if (srvRequest.getID3() != null) minScore = (float) (minScore + 5.5); if (srvRequest.getID4() != null) minScore = (float) (minScore + 5.9); minScore = 2; return minScore * probeility / 100; }
Randy added, "at least the method uses 'probeility' in its determination."