Friday, May 19, 2017

How to differentiate between an Average and a Good Programmer?

When it comes to interview, goal is to find the most suitable developer for job to get done but its very difficult to judge someone's caliber, experience and expertise in short duration of Interview. There is always a process starting from phone interview, written tests to face-to-face interview, but its still difficult to hire the right programmer. Process can help you to filter candidates but eventually it will come down to your experience and gut feeling. As you take more and more interviews, you will know what to ask and what not and like many other interviewers in the world, you will develop some of your own tips. Similarly, I have developed couple of tips from my experience which has helped me to differentiate an average programmer with a good programmer in past. Today I would like to share one of such tips with you guys, to see if you agree with my observation and hopefully I will get couple of more tips to find right programmers. One of my most used tip is finding gaps in requirement. I have found and learnt it over time that good developers has knack of breaking requirements and finding gaps, which is very important to produce quality software and products. Though this skill comes with experience, a good developer even with less experience has this ability. In this article, I will share my hypothetical interview with two programmers and see what they produced.

Average Programmer vs Good Programmer

This is an hypothetical interview to demonstrate my tip, but its very close to real interview. BTW, You can change the requirement based upon your domain, candidates experience and his domain expertise and job description. Key is to give one line requirement to candidate and compare the quality of program developed by multiple programmers. In this scenario, I have used a very general requirement, which doesn't need any domain expertise e.g. finance, healthcare or manufacturing,  but require some programming experience.

Interviewer : Can you write a script to archive files older than 30 days and which can be run on 1st day of month using cron job?

Programmer 1 went on to code and produced a script which does exactly what is in requirement. His script can find all files in a directory provided as input, can create archive on same directory with provided name and backup date as suffix. Looks good right? but hold on something is missing :

1) He did not excluded archive files created by script itself, which means in second month script will also include last month's archive. If you are not monitoring, you will only realize this problem when you need to retrieve something from archive.

2) He did not think about two contradicting part in this script, finding files older than 30 days and running it on 1st of every month. Since script's objective here is to backup last month's data and month can be any of 28, 29, 30 or 31 days. So if you run this script on 1st march, it will not archive any files because all of them are less than 30 days old because February is usually 28 day long.

3) His script was not removing files after archiving. Though this was not stated as part of requirement, its an implicit requirement, until interviewer specifically mentioned not to do so.

These are just some of examples of missing requirements but this case is quite common in real world programming. Most of users gives requirement like this and experienced programmer know that "devil is always in details". Before doing anything, first step is to understand the purpose and then think what is missing. Just like when you go to doctor and says that you have some problem, he asks couple of questions to better understand the problem, you should always ask questions to clear doubts, let user know what is missing etc. As an expert on area of software development its your responsibility to get enough details so that product meet user expectation and can withstand test of time. I like to ask this kind of question which is not very domain specific and very general in nature. This not only gives an opportunity to gauge candidate's expertise on a any particular technology e.g. Perl, Python or Bash script but also his overall thinking process. Any developer, who can think through and find gaps in requirement is going to be an asset for team. BTW, like all the things this is not always the case and its not a hard and fast rule, It's just another indicator, which can potentially help you to find good programmers.

Here are couple of more examples to differentiate between an average programmer and good programmer. One of the interesting task is to ask developer to write code to read a file, a good programmer always ask questions about file content e.g. binary or text, if text then what is the encoding, while an average developer just write the code to read the file. Good developer will make sure to close streams in right way and release file descriptors while an average programmer forget about that.

Another example is about asking candidates about how to quickly sort any array, most of them will tell you about quicksort algorithm, but good developers will ask about the size of the array. Why? because if the array is small enough, then the fastest way to sort it will be to use insertion sort. In fact most of the library methods which are based upon quicksort will usually use insertion sort for small arrays. Like in Java API, the implementation of the Arrays.sort() method sorts small integer array of less than 286 element using quicksort and tiny array of elements less than 47 using Insertion sort. BTW, this is another reason to follow Joshua Bloch advise of always using library method if available. You will never get this kind of optimization right in short duration of writing your library, forget about all the testing users have done on open source library.

Average Programmer vs Good Programmer

Task based Questions for Interviews

For developers and programmers, if you get these kind of questions, where Interviewer ask you to do a real job, consider understanding requirement better and asking right questions. Like in our previous question, you could have ask about all those missing requirement which surface when you start using your script. Needless to mention that second programmer was bit more intelligent and practical and was able to fill some of those gaps.

Here are couple of more question for your practice :

1) Write a wordwrap() function, which can take a String and break it based on screen size?
This was a real Java ME interview question, which appeared when mobile devices are very small and don't have enough API support. Since mobiles has varied screen sizes, wrapping words based upon screen size was a common task. Though not stated, goal here is to make this function work for every device. Function should consider line breaks, white spaces, font sizes etc. You can now use this question for Android and iOS interview, as smartphone sizes are still not uniform.

2) Write a function to replace a given character from an String in Java?
This is rather simpler one but ask him to write a production like code and then see if it takes care of obvious things like null string, empty string, String contains all character which is there to replace etc, here is the sample solution of this problem.

That's all about this tip to differentiate an average programmer with a good programmer. As I said this is just one of several points many Interviewer looks on a candidate, For programmers It's an opportunity to show their think through ability and how good they are in understanding requirements and finding gaps. This tip has helped me in past but its not hard and fast rule to find good developers, in fact there is no rule to find them. You just have to work through some indicator and your gut feeling. Let me know what are the tips you guys are using to find good programmers on interviews.

Further Learning
Design Pattern Library
Soft Skills: The 11 Essential Career Soft Skills
Data Structures and Algorithms: Deep Dive Using Java
Algorithms and Data Structures - Part 1 and 2

P.S. - If you want to become a good programmer, don't forget to read these 10 tips and these 10 articles.


Anonymous said...

"...a script to archive files older than 30 days ..."

ad.3. The assumption of removing files after archiving is questionable.

Well, I think you're wrong.
There's nothing identical between "... to archive files older than 30 days ..." and "... to backup last month's data ...", so no contradiction in running the script 1st day of every month to find items OLDER than 30 days from now.

The script looks 30 days back and from that time in the past it looks NOT for younger but for OLDER items and it will find them (provided there are some created/modified/accessed(?) more than 30 days ago).
Everytime the script is to be run it has moved forward (28/29, 30 or 31 days) in time and it has just covered another period of past time.

jonas brothers said...

come on this is all arguable questions.

Anonymous said...

Are you really expecting someone to be able to know/remember all of the APIs methods to write a wordwrap function on right on the interview? What time frame do you give for this?

Anonymous said...

@Anonymous, I think its not about remembering API, its about developing API with common methods e..g length(), split(), count() etc. I did find the wordwrap question interesting, especially a general solution which can be used across different devices which has different width. Key thing is you need to break words before length of sentence is greater than screen width, but if you are at middle of the word then you need to backtrack.

Anonymous said...

@Jonas brothers,
Even though questions are aguable, you need to ask those question and put your argument forward, that itself shows that you have think through ability which many programmers lacks.

Anonymous said...

"3) His script was not removing files after archiving. Though this was not stated as part of requirement, its an implicit requirement, until interviewer specifically mentioned not to do so."

what a bullshit article

Javin Paul said...

@Anonymous, Why BS? Don't you want to do cleanup? its one of the sign of professional developers. Just saying BS doesn't doesn't prove anything, if you have any argument then please put forward.

Saad Alfoudari said...

The purpose of archiving should be known to expect what should that imply. If I want to continue working on these files and just want to back them up, I certainly wouldn't want them to be cleaned out. Instead of expecting the programmer to do what you think should be done implicitly, what would be a better indicator in my opinion is to see how the programmer tries to ask questions on the scope of the program, purpose, usage and limitations explicitly. Unless the programmer is very familiar with the purpose of the program, he/she should not assume what is not stated, but should try to elicit them.

Javin Paul said...

@Saad, Indeed you pick the right point. The whole purpose was to see whether programmer can ask right question about requirements and whether he has relevant experience or not. I agree, in most cases though archiving will followed up by cleanup but its not necessary and if you as candidate not sure, you should ask.

Vivek Agrawal said...

Deleting the file after archiving qualifies as an implicit requirement. If developer is not deleting the file after archiving then either he doesn't know the meaning of archiving or he is simply careless.

Anonymous said...

i hope you rely more on the "way the programmer thinks" rather than on the plain code produced. i mean, good programmers make mistakes as well, good programmers are not robot and during an interview can get emotional and write bad code, when good programmers are not happy with the code they write in a session usually they go to sleep thinking about it and wake up with a solution in mind.. etc

Paddy3118 said...

The candidate may decline working for a company that routinely gives bad requirements.

Javin Paul said...

Hello Paddy, may be but I see this as a good question, candidate should discuss, interview is opportunity for both parties to find out more about each other.

Anonymous said...

This is silly. There is not end to programmer asking for questions and conforming to implicit requirements.
30 days, As per which time zone? Should the files be deleted or moved to recycle bin? What about large files should they also be moved to recycle bin? Is cron job going to be run as same use or super user? What if disk becomes full while creating archive, should it also email an alert? What about sending text? Trilio or Sendgrid? Do you also need a UI for configuring the emails alert? Native UI or Web UI? Mails need to go via TLS or SSL? What version of TLS? Do you have self signed certs for the mail server? Is there a CRL too? What about sending SNMP traps when errors happen? Do you also want syslog to be sent? Any rate limits?
A programmer is to conform to given requirements. Lets not ask him to cover for sloppy requirements.

Post a Comment