Finding a new job – interviews (coding)

I recently went thought the processes of finding a new job. It’s a difficult time as you’ve previously been employed with an employer who values your work (hopefully) and now have 1 hour to prove to a potential new boss that you’re not just like everyone else they’ve interviewed that day.

I went to interviews at about 8 different places and all were different. Despite what websites say, there is no way to prepare for an interview. Each one is unique and the one thing I find is to always be honest. Definitely do not sit there and tell the interviewer something that you do not know / know to be a complete lie! You’ll soon be found out. Plus telling the truth can often work on your side. I started most of my interviews by pointing out that I was a junior Java developer who hadn’t read or done anything with design patterns.

Each of the interviews was completely different. I had one company that asked me to talk through code that wasn’t written by me to see how much of an understanding I had of Spring, Hibernate and whether I could guess what the Struts code was doing. Another company grilled me for an hour on fairly taxing questions about hierarchies in databases (luckily I’d been working on hierarchies for the last two years). I only had one really uncomfortable interview which was not something I’d like to repeat too soon.

I got my latest job last October after 4 months of being out of work and didn’t have to dip into the savings too much 🙂

 

One thing I did find interesting from my interviewing time was the online interview I took part in. It was a fairly simple test (I think I must have passed as I got a second interview) which tested core coding skills without wasting too much of the (interviewing) companies time if I wasn’t up to standard.

The interviewer directed me to a site where I could type in the large text box and he could see the result immediately, similar to http://ietherpad.com/, but a lot more simplistic.

I was then asked to write a method that would take an array of integers and return the integers which are divisible by 3 leaving no remainder.

public List<Integer> divisibleBy3(int... args)
{
	List<Integer> results = new ArrayList<Integer>();
	if ( args != null && args.length > 0 )
	{
		for ( int i = 0 ; i < args.length ; i++ )
		{
			if ( args[i] % 3 == 0 )
			{
				results.add(args[i]);
			}
		}
	}
	return results;
}

Yes, the name of the method is not great, but it does the job!

After finishing that method, the interviewer (cleaned up where necessary) ran my code against a test suite he had and then proceeded on to the second test. He didn’t actually tell me if I’d gotten it right.

Second method: write a method which takes an array of numbers and reverses the numbers in the original list(!). The method should not make use of any utilities provided by the language (E.g. Arrays.*). I had to ask for the instructions twice, but once I started coding was surprised how quickly I knocked my answer out.

public void reverseArray(final int[] varargs)
{
	if ( varargs != null && varargs.length > 0 )
	{
		int[] reveresedList = new int[varargs.length];
		int loopInd = 0;
		for ( int i = varargs.length ; i > 0 ; i-- )
		{
			reveresedList[loopInd] = varargs[i - 1];
			loopInd++;
		}
		
		for ( int i = 0 ; i < varargs.length ; i++ )
		{
			varargs[i] = reveresedList[i];
		}
	}
}

 

So what do those coding tests prove? A basic understanding of the language and that you aren’t just someone who claims they can code. It doesn’t check much other than that, but it could weed out a lot of potential candidates with relatively little effort. I went for a second and third interview with that particular company. The online coding interview certainly cannot replace the need to interview people face to face, but it can help reduce the list.

I’m guessing I’ll get a question about why they didn’t choose an online IDE shared page, like http://cloud9ide.com/. Well that’s actually fairly obvious, they were testing my skills, not the IDE which can auto complete and check obvious errors.

 

One more thing, if you’re thinking this would be a useful tool, you’ll also need some junit tests to go with it (or you could write your own!)

	@Test
	public void testReverseArray()
	{
		int[] i = new int[7];
		i[0] = 10;
		i[1] = 9;
		i[2] = 6;
		i[3] = 5;
		i[4] = 4;
		i[5] = 7;
		i[6] = 8;

		reverseArray(i);
		assertEquals(i[0], 8);
		assertEquals(i[1], 7);
		assertEquals(i[2], 4);
		assertEquals(i[3], 5);
		assertEquals(i[4], 6);
		assertEquals(i[5], 9);
		assertEquals(i[6], 10);
	}

	@Test
	public void testDivisibleBy3()
	{
		int[] i = new int[7];
		i[0] = 10;
		i[1] = 9;
		i[2] = 8;
		i[3] = 7;
		i[4] = 6;
		i[5] = 5;
		i[6] = 4;

		List<Integer> integers = divisibleBy3(i);

		assertEquals(integers.size(), 2);
		assertTrue(integers.contains(9));
		assertTrue(integers.contains(6));
	}