Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Interview Question

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Interview Question

    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:
    Write a command line app that takes 2 parameters, city and state, and then outputs latitude and longitude (extracted from Google Maps).
    Reviewer 1:
    - 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
    Reviewer 2:
    - 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.
    The Code:
    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;
    		}
    	}
     
    }


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    90
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: Interview Question

    I do not have experience,but not writting a single comment is a disadvantage for sure.This also should be in great consider "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 "
    Also the 4 point,for variables is also a disadvantage.However an experienced develop could judge all this,not me.

    An interested(i think) idea is to show the candidate the complaints of the one developer and let him justified.An interested² idea is to have the develop that wrote the 'bad for the candidate' report in contact with the candidate in order to letting the candidate explain why he did so.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,453
    My Mood
    Hungover
    Thanks
    144
    Thanked 638 Times in 546 Posts

    Default Re: Interview Question

    Was this an on-the-spot assignment? How long did you interviewee have?

    If this was an on-the-spot, 10-minutes interview code session, then was reviewer 1 having a bad day? Seems pretty unfair to come to all of those judgments based on a tiny section of code, especially since some of those criticisms could be argued against, and double especially if the code works.

    If the interviewee had time to mull it over and do this at home with the aid of the internet, then perhaps a harsher judgment is in order. It's really up to you though. We don't work for your company, so we don't know what you're looking for in a candidate.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Interview Question

    I agree with KevinWorkman. It depends somewhat on how long the interviewee had, as well as the goal of the code.

    High quality code which has the potential to be interfaced in several areas should be well documented, structured well, and perform reasonably.

    However, if the code is a small utility with a "single use" mentality or as a proof of concept these issues are less important. There have been many times where I have written utility code which have horrible styling and/or performance but the project was completed much quicker than a full well designed program. In business often time the top of the line bells and whistles simply isn't required. It's a balance between cost/time and quality.

    My general remarks if this was code designed for integration into end user products:

    1. Lack of comments, especially method documentation.
    2. Poor variable names.
    3. I don't necessarily agree with the program structure. Personally I would like to see and OO solution, especially for code that is intended to be integrated with other code.
    4. I can't comment on the performance. DOM structures and Java networking are not really in my area of expertise.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,334
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: Interview Question

    From my standpoint it seems to boil down to what the code was meant to test. One could read it from the standpoint of testing their coding ethics, another from the standpoint of getting the job done. When I read between the lines, the term 'command line app' and its context in the question suggests to me to get the job done with as little fluff as possible - its a tool that will be used, not code that will be reused. And that is what the code posted does - it gets the job done. If that is not what the question was supposed to test, then with all due respect it is poorly worded. If it were rephrased, for instance "create a package which....", or "create a library which...", or "implement x interface, the implementation does..." (something to suggest code reuse) the question would suggest something entirely different. From my point of view the interviewee completed the requirements. Did they go the extra mile? No...reviewer 1's points are quite valid in this context. But, are you testing whether they will go the extra mile, or get the job done?
    Last edited by copeg; August 7th, 2012 at 02:43 PM.

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Interview Question

    Review of reviewer 1:
    1 & 2: agreed, somewhat.
    3: agreed harshly. No excuse for lack of comments, especially in a group environment.
    4: as far as the string named s, ok a better name could have been used. As far as x being used as the index in a for loop, reviewer 1 should not have listed that...
    5: this whole line is just a recap of 1-4.
    My opinion:
    I get the impression reviewer 1 has unknown-to-the-public reasons to be so harsh on the author of the code.

    Review of reviewer 2:
    Nothing specific was said about the code, where there was plenty to be said.
    My opinion:
    Comments like that of reviewer 2 are the type comment a friend would say about a friend, or a stranger could be paid to say. It promotes the idea of hiring the author for the job without sticking reviewer 2's neck out too far.

    Review of the code itself:
    1)No comments
    2)Access modifier missing for class definition
    3)Poor class name for the purpose of the class
    4)Although there is a javadoc line that says @param args and @throws IOException, this can not be counted, as it says nothing about what the args are for, or anything useful at all.
    5)The string "Not enough parameters" could have been more elaborate to the problem.
    6)I am not overly impressed with the code in the catch block.
    My opinion on the code:
    The code demonstrates the author's ability to get the job done. As far as the DOM, not my area of experise either, but if there is a better way known to reviewer 1 and/or your company, introduce it to the author and get another code sample. In my opinion of the author, he/she demonstrated the ability to get it done with what is in his/her head. If he/she demonstrates the ability to pick up on your company's local ways, and adapt both himself/herself as well as the company to better ways, I say you have found yourself a worthy candidate. I wouldn't expect to find a perfect page of code from anyone applying for a position in a new company.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,453
    My Mood
    Hungover
    Thanks
    144
    Thanked 638 Times in 546 Posts

    Default Re: Interview Question

    Quote Originally Posted by jps View Post
    No excuse for lack of comments, especially in a group environment.
    Have you worked in a group environment? Man, I'd love comments at my job...
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Frequent Interview qn
    By tcstcs in forum Java Theory & Questions
    Replies: 3
    Last Post: May 9th, 2012, 09:35 AM
  2. eclipse interview questions and answers
    By saggammahesh in forum Java IDEs
    Replies: 1
    Last Post: April 17th, 2012, 02:07 AM
  3. Replies: 0
    Last Post: June 9th, 2011, 08:16 PM
  4. JAVA INTERVIEW QUESTIONS
    By kanchana1 in forum Java Theory & Questions
    Replies: 4
    Last Post: June 8th, 2011, 08:23 PM
  5. Getting ready for an interview
    By Charlie in forum The Cafe
    Replies: 5
    Last Post: June 4th, 2010, 07:25 PM