為什麼程式員不會編程?

來源:互聯網
上載者:User

  人生真的很有意思,三年前我坐在面試官的位置上,面試別的程式員,現在我坐在程式員的位置上,等待被別人面試。

 

  三年前我跟朋友合作在廈門開始創業,做對歐美的軟體外包開發。當時困擾我們最大的問題之一就是找不到會編程的程式員。往往收到四,五十份簡曆,到最後只有一兩個應聘者能通過我們的編程測試。其實測試的題目也不難,像bubble sort之類的問題。現如今,從荷蘭回來,需要找一份工作,卻發現找到一家好的公司好的工作也不容易。最近通過部落格園的招聘板塊,投出去一些簡曆,也陸續接到一些面試的反饋。

 

  在為即將來臨的面試作準備的時候,發現網上的一篇文章《Using FizzBuzz to Find Developers who Grok Coding》裡面講到,

  After a fair bit of trial and error I’ve come to discover that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.

  So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call “FizzBuzz Questions” named after a game children often play (or are made to play) in schools in the UK. An example of a Fizz-Buzz question is the following:


  Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.


  Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes.Want to know something scary ? – the majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.


  這段文字的大意是講到作者在面試程式員的時候發現那些不會解決編程小問題的程式員通常也不會解決技術中的大問題。所以他設計了一道面試題目,可以協助他發現不會編程的程式員。題目是這樣的,寫一個程式列印出1到100之間的整數,如果這個整數能被3整除,用"Fizz"替換這個數字,如果這個整數能被5整除,用"Buzz"替換這個數, 如果這個數能被3和5同時整除, 用"FizzBuzz"來替換這個數. 好的程式員應該在幾分鐘之內寫出這樣的程式. 但是讓作者感到恐怖的是, 大多數電腦專業畢業的學生都沒有辦法在幾分鐘之內寫出這個程式. 而且有些自詡是進階程式員的程式員也花了超過10~15分鐘的時間來完成這段程式.


  為了測試以下自己是不是會編程的程式員, 我也趕緊地開啟Visual Studio, 5分鐘後, 版本1出世, F5, 列印出 1 2 Fizz 3 4 Buzz .... (心中暗想應該先寫測試的, 沒有TDD), 然後趕緊回到代碼發現自己的邏輯錯誤, 修改, 2分鐘後, 運行,  1 2 Fizz 4 Buzz .... 還好, 結果正確, 雖然是沒有Unit test. 再看看代碼, 有點長, Refactor 一下, 搞定.


  你是一個會編程的程式員嗎? 不防也做做這道"FizzBuzz"的面試題目, 記得紀錄一下你的時間哦.


我的"FizzBuzz" C# version


 1 using System;
2  using System.Linq;
3
4  namespace FizzBuzz
5 {
6 class Program
7 {
8 static void Main(string[] args)
9 {
10 var numbers = Enumerable.Range(1, 100);
11 foreach (var number in numbers)
12 {
13 if (number%3 == 0 && number%5 == 0)
14 {
15 Console.WriteLine("FizzBuzz");
16 }
17 else if (number % 3 == 0)
18 {
19 Console.WriteLine("Fizz");
20 }
21 else if (number % 5 == 0)
22 {
23 Console.WriteLine("Buzz");
24 }
25 else
26 {
27 Console.WriteLine(number);
28 }
29 }
30 Console.ReadKey();
31 }
32 }
33 }
34  

 

更新(2010.11.11 00:55) :

Jeff Wong 在他的文章 <也談求職中的fizz-buzz-thing,兼談程式員為什麼不會編程>中對本文是個很好的補充. 代碼也比較簡潔, 跟評論中六樓童同的比較類似.

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.