Interviewing a software engineer / developer / programmer

I am going to have a face-to-face interview with a candidate of a PHP programmer position this afternoon. I was told to prepare some technical questions for the interview.

If a candidate earns an face-to-face interview opportunity, that means his resume should have a very good match to the position requirement. However, people can put anything on their resumes, there is no way to tell whether the information on the resume is true or not (and referencees guarantee will give you good feedback on the candidates). That’s why a face-to-face interview is really important.

I will have around 30 minutes to 1 hour to interview a candidate, how can I get the most information from him to help myself making this decision?

After googling on the web, I found tons of information about how to interviewing a programmer, but most of them are related to really technical questions, such as “How do you solve this math puzzle?”, or “What’s the meaning of double-dollar variable in PHP?” etc. I think these questions are not efficient and effective enough to judge the skill of the candidates. Personally, I don’t like these types of questions at all because I think it does not help to judge a realistic performance of a person. I prefer some more realistic questions.

So, I end up designing a test by myself. It is nothing more than a simple html form (e.g., a form to update users’ contact information). The candidate will be asked to implement the functions to update the records. I think this is pretty closed to what I do in my work, i.e., Create, View, Update and Delete record.

Well, this question sounds pretty simple, and I think there are plenty of hidden traps. Here are what I expect in the codes:

  • Core function, i.e., Updating the record – 40%
  • Validating the inputs(e.g., don’t store a negative number into age column, make sure the ID exists etc) – 10%
  • Performance (e.g., Update the record only if the records have been changed by the users.) – 10%
  • Handling simultaneous update (e.g., lock the record before update) – 10%
  • Security (e.g., storing the configuration out of the web server scope, prevent online attack etc) – 10%
  • Development time(e.g., spending 2 hours ends up with very few features is not acceptable) – 10%
  • Think outside the box(e.g., Suggesting to use Ruby on Rails to shorten the development time, using jQuery for client-side validations etc.) – 10%

I believe that if a person can do great in a simple task, he will do great in a complex task. Unfortunately, it is not easy to look for a good programmer.

Updates (August 31, 2009):

The answers I received from the candidates are pretty interesting and filled with tons of surprise. Some of the answers go beyond my imaginations. Here are few examples:

  • One candidate sent me a package with all of the source codes. Unfortunately, none of the codes works. Apparently, he forgot the golden rule of software development: A software must work.
  • Another candidate sent me a package with tons of files. After I read the codes, I found that the codes were copied from other projects with very minor modifications. This kind of candidates should be avoided because cleaning up the code is a basic responsibility of a programmer.
  • A candidate has spent a lot of efforts on defining the variables (More than 20 variables were defined in the configuration sections), but he only put one line of comment (and no code implementations) inside the validation function, i.e.,
    //Validation goes here...

    He would impress me if he included at least one validation example.

  • One of the submitted answers is even more interesting (and ridiculous). It was created via some PHP-MySQL wizard websites. Although the result works fine (of course!), he does not receive any credit because his programming skills could not be proven.

So far, the best answer scores 60%. I don’t think this is an exciting result. If you found this useful, please let me know, thanks!

–Derrick

Our sponsors:

Does the most popular imply the best?

Today, I had a discussion with my co-worker on the best languages for web applications. While I argued that Perl, and Ruby performs better than PHP, my co-worker had an opposite opinion. He believed that PHP is the best language overall because it is widely used. It brings me to think of a question, does the most popular imply the best?

Let’s answer this question by examples:

Category Most Popular The Best Why The Best?
OS (Desktop) Windows OS X User friendly, secure, stability, and performance.
OS (Server) Linux, Windows Server FreeBSD Fast, stable, secure, simple design, and centralize management.
Browsers Internet Explorer, Firefox Safari Fast, secure, stable
Programming languages (Desktop/GUI) C#, Java C, C++ Fast, secure
Programming languages (Web/Server) PHP, ASP Ruby, Python, Perl Fast, fewer lines of code.
Database MySQL, Oracle Berkeley DB, Tokyo Cabinet Fast I/O, simple design, smaller size of the database file.
Software company to work for Microsoft Start-up Rewards, opportunity to grow

I think there are several reasons why the most popular things are not the best.

1. Most popular thing is always backed by the best marketing strategies. Marketing strategies is simply a way to let people know about the product and convince them to use it. It has nothing to do with the quality of the product at all.

Example: The ads of Internet Explorer 8 look very attractive. Is it the most secure browser ever?

2. Most people are followers. They are not good in selecting good products from bad products(i.e., filtering the noise). They believe that the choice form most people (most popular) should be the best one. This is similar to election. The choice of most people is more likely to be better.

Example: Is MySQL really the best database?

3. Different people have different preferences. So a popular product must have the general taste. For example, an extremely hot and spicy food may be better to the body, but it is not as popular as a mild one, because the number of people that can take extremely hot and spicy food is smaller.

Example: Linux is very easy to configure comparing to FreeBSD (GUI vs command line) from the end-user perspective, but it is less powerful and stable overall.

Conclusions:

Think twice before your move.

Our sponsors:

Example PHP code to convert a number to an Excel column letter

I was looking for a good way to convert a number to the Excel column letter, for example:

1 -> A
26 -> Z
27 -> AA
28 -> AB
800 -> ADT

etc.

After searching on Google, I could not find any algorithm I want. (The closest one can handle up to two letters, i.e., ZZ. It will crash if the number is too large.). So I ended up creating my own.

Basically, you can think of this problem as a 26 based number conversion. Here is the php version. It should be pretty simple to convert it to a different language. Let me know if you have any problem.

function columnLetter($c){

    $c = intval($c);
    if ($c < = 0) return '';

    $letter = '';
             
    while($c != 0){
       $p = ($c - 1) % 26;
       $c = intval(($c - $p) / 26);
       $letter = chr(65 + $p) . $letter;
    }
    
    return $letter;
        
}


Usage:
columnLetter(1303618093);    //DERRICK

Note that if you prefer lower cases rather than upper cases, you can simply replace 65 by 96 in the code.

Enjoy~!

–Derrick

Our sponsors:

“mount_smbfs: kldload(smbfs): Operation not permitted” SOLVED!!!!

When I tried to mount a windows share from FreeBSD:

sudo mount_smbfs -I WindowsBoxIPaddress //username@WindowsBoxIPaddress/WindowsShare /mnt

I always got this error:

mount_smbfs: kldload(smbfs): Operation not permitted

After searching this error message on Google, I found that all suggested solutions were related to running this command using sudo, which I already did. Today morning, I tried a different way and the problem is solved!

In /etc/rc.conf, I disable the following configurations:

#kern_securelevel="1"
#kern_securelevel_enable="YES"

After I rebooted the machine, and mounted the Windows share again, it worked! That’s simple, isn’t it?

Note: These two lines are for making the FreeBSD box more secure, and I highly recommend to put these in a public accessible server. I don’t think it is safe to make a public accessible server to access to any Windows box because there are not many protections you can do on a Windows box. In case the public server got hacked, the connections to other internal servers should be blocked, i.e., other internal servers can always access the public server, but not vice versa.

–Derrick

Our sponsors:

Bandwidth Tester Add-on for Firefox 3.5+

I always go hunting the Wi-Fi networking using my laptop. Everytime I got on a new Wi-Fi network, I like to measure its bandwidth. I found that Bandwidth Tester is pretty handy and I can get a result easily. If you are looking for this tool to work on Firefox 3.5+, here is a work-around version I created:

Download Bandwidth Tester 0.5.9 Add-On for Firefox 3.5+ here.

Enjoy~

…And if you want to use any Firefox Add-on on Firefox 3.5+ but it is not available, feel free to let me know! Don’t forget to include the link. Thanks!

Our sponsors:

CopyPlainText Add-On for Firefox 3.5+

CopyPlainText is one of my favorite Firefox add-ons because it can filter out all of the formatting and leave the text alone. It is an amazing tool especially when editing non plain-text editor such as Microsoft Word etc.

After I upgrade to Firefox 3.5, I found that this add-on is no longer available. Therefore, I created my work-around version here. No functionality has been changed, except it works fine in Firefox 3.5+ šŸ™‚

Download CopyPlainText 0.3.4 for Firefox 3.5 from here.

Enjoy~!

…And if you want to use any Firefox Add-on on Firefox 3.5+ but it is not available, feel free to let me know! Don’t forget to include the link of the apps.

Our sponsors:

BlockSite Add-On for Firefox 3.5+

Please visit here if you are looking for BlockSite for Firefox 4.0.

Thanks!

I love using BlockSite along with AdBlock Plus to filter the unwanted content in my Firefox. However, after upgrading to Firefox 3.5, I found that the BlockSite is no longer supported in this version. After waiting for a month, I found that the new supported version is not available, and therefore I created my own version.

Here you are, and enjoy it!
Download BlockSite 0.7.1 for Firefox 3.5+

…And if you want to use any Firefox Add-on on Firefox 3.5+ but it is not available, feel free to let me know! Don’t forget to include the link. Thanks!

Our sponsors:

Tokyo Cabinet is 31 times faster than MySQL!!!

Today I was comparing the performance of Tokyo Cabinet, MySQL and Memcached using PHP. The result of Tokyo Cabinet is really impressive!

(Note that these results are generated from my computer. If you perform your own benchmarks, then you might find different results due to different system configurations. In fact, I encourage you to perform your own benchmarks. )

1. Quick Result

Total time used to write 10000 records and retrieve them back by each candidateĀ  (The lower the better):
Tokyo Cabinet: 18.87s
Memcached: 11.309s
MySQL: 562.21s

A completed result will be given below.

2. Testing environment

Hardware

  • Intel Pentium II 450MHz
  • 160 MB RAM

Software

  • FreeBSD 7.2
  • Apache 2.2.11
  • PHP 5.2.9
  • Tokyo Cabinet 1.4.20
  • Tokyo Tyrant 1.1.26
  • MySQL 5.1.34
  • Memcached 1.2.6

3. Test scenario

For each candidate, I measure its performance using the following strategies through PHP:

1.) The time used to create all of the necessary objects.

2.) The time used to connect to the database.

3.) The time used to store 10000 randomly generated data.

4.) The time used to read 10000 randomly generated data.

5.) The time used to close the connection.

4. Test results

Tokyo Cabinet

time index ex time %
Start 1243136772.72818600 0.00%
create 1243136772.72838700 0.000201 0.00%
connect 1243136772.73224200 0.003855 0.02%
vanish 1243136772.73526800 0.003026 0.02%
put 1243136781.53287200 8.797604 46.60%
get 1243136791.60574800 10.072876 53.35%
close 1243136791.60755900 0.001811 0.01%
Stop 1243136791.60782300 0.000264 0.00%
total 18.879637 100.00%


Memcached

time index ex time %
Start 1243131185.86078100 0.00%
create 1243131185.86092500 0.000144 0.00%
connect 1243131185.86688300 0.005958 0.05%
put 1243131191.49702900 5.630146 49.78%
get 1243131197.16868100 5.671652 50.15%
close 1243131197.16982400 0.001143 0.01%
Stop 1243131197.17003400 0.000210 0.00%
total 11.309253 100.00%

MySQL

time index ex time %
Start 1243136138.19049000 0.00%
create 1243136138.19064700 0.000157 0.00%
connect 1243136138.22529900 0.034652 0.01%
put 1243136150.70760600 12.482307 2.22%
get 1243136700.40063700 549.693031 97.77%
close 1243136700.40078900 0.000152 0.00%
Stop 1243136700.40104500 0.000256 0.00%
total 562.210555 100.00%

The overhead time (create objects, making connections, closing connections etc) of all candidates are about the same. The only difference is storing the record and retrieving the record. Both Tokyo Cabinet and MySQL took about 10 seconds to store 10000 records in the database. However, Tokyo Cabinet took about 10 seconds to retrieve the records while MySQL took about 550 seconds! That’s about 31 times longer!

benchmark-tokyocabinet-memcached-mysql

5. Materials

Here is the material I used to make this benchmark test.
Click here to download the package.

Please feel free to let me know if you have any question or comment.

Our sponsors:

Oracle, MySQL and Berkeley DB, what’s next?

When Oracle acquired Berkeley DB, the quality of Berkeley DB has gone worse after that.

Now Oracle acquired Sun who owns MySQL, will the history repeat again?

(By the way, I am going to fall in love with Tokyo Cabinet.)

Tokyo Cabinet is now the new black.

Our sponsors:

Thoughts on Quality Assurance on Software Testing

Recently I developed several projects using Ruby on Rails.Ā  One of the cool features of it is the built-in test tools. With this amazing tool, I can test my web page such as data validation in few seconds by myself. It reminds me the time how a software was tested in the company I worked for previously.

In the formal company I worked for, they had a very well Quality Assurance Team for testing the software functionality(The ratio of developer to QA is about 3:2). Usually we (developer) need to come up many test cases for them (e.g., testing the data field with positive, negative or invalid value) because the QA team does not have any technical background. Other than that, the QA team would only focus on the GUI level testing, such as whether this control is aligned with the label or not etc. One of the key components that has been ignored is the stress test.

I still remember that I developed a resource-consuming feature, and I was worrying about its impact of overall performance when many uses are using this feature at the same time. So I talked with my QA and see what he think. Initially I expected that he would run a stress test (e.g., simulating 100 thousands of users to use the feature at the same time), and guess what his answer?

I can schedule an appointment with the rest of the QA team, we can sit down together and try to use your feature at the same time.

No, this is not a joke. In fact, about a month later, someone from other application team really does something fancy about it. They sent out a mass email and ask people to sign up. They end up having about 900 uses to use the application at the same time. That’s about 1/3 of the whole population in the company!

I think it is kind of stupid to ask 1/3 of the whole company to do a simple test, which can be done using computer automatically! Think about how expensive is the test:

900 people x $40/hr x 2 hour = $72,000

With this amount of money, they can probably hire one to two QAs to work on the test for a year!

Our sponsors: