Hello,
I hope some of you can help us make a decision and break a deadlock. We've been interviewing a candidate for a developer/sr. developer position and he's been doing very well. He was then asked to write a sample program, which was reviewed by a developer, who gave the candidate a very bad assessment (you can see his comment below). That caught us by surprise, since the candidate has an impressive resume and the interview process was going very well, so we asked a second developer to review the code and he came back with a positive assessment.
Can any of you weigh-in on the matter and help us make a decision. Thank you.
Requirements:
Reviewer 1:Write a command line app that takes 2 parameters, city and state, and then outputs latitude and longitude (extracted from Google Maps).
Reviewer 2:- Source demonstrated very poor coding practices:
1) non-modular, very "spaghetti" like code
2) orphaned code in a primary project;
3) no comments;
4) non-descriptive variable names (i, s, x, in).
5) poor coding practices, especially for a team environment.
- Very poor performing source. Use of DomBuilder and DOM factories causes extreme overhead. No use of parsing primitives for performance yields resource requirements easily 10x of what should have been used.
- Candidate is a Junior-MidGrade coder that would do best on a very large team where his roles would include code-like duties but nothing related to actual source.
- high performance code would most likely suffer significantly if similar code was used in that project
The Code:- no significant problems were found in the code. Based on the code provided and the positive interview feedback, the candidate should be considered for a developer/sr. developer position.
import java.io.*; import java.net.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; class Finder { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { if (args.length < 2) { System.out.print("Not enough parameters"); return; } else { System.out.println("City = " + args[0]); System.out.println("State = " + args[1]); } String s = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + args[0]+ " " + args[1] + "&sensor=false"; s = s.replaceAll(" ", "+"); //s = URLEncoder.encode(s, "UTF-8"); URL theurl = new URL(s); URLConnection uc = theurl.openConnection(); BufferedReader in = null; in = new BufferedReader(new InputStreamReader(uc.getInputStream())); String inputLine; StringBuilder sb = new StringBuilder(); while ((inputLine = in.readLine()) != null) { sb.append(inputLine); } in.close(); parseReturn(sb.toString()); } private static String getTagValue(String sTag, Element eElement) { NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes(); Node nValue = (Node) nlList.item(0); return nValue.getNodeValue(); } private static void parseReturn(String xml) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(new InputSource(new StringReader(xml))); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("geometry"); for (int x = 0; x < nList.getLength(); x++) { Node nNode = nList.item(x); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element geoElement = (Element) nNode; System.out.println("Longitude = " + getTagValue("lng", geoElement)); System.out.println("Latitude = " + getTagValue("lat", geoElement)); break; } } } catch(Exception e) { return; } } }