原文:http://www.quora.com/Software-Engineering/How-do-top-programmers-work First, they do NOT do a lot of things:
They do NOT reinvent a wheel. There's lots of new stuff to do and no time to waste redoing what others have done well. If there are libraries, gems, code snippets, examples, etc they will happily use the tools available and spend their time on the new stuff. They do NOT write code for features they do not need. In other words they keep it simple. When writing something it's common to think "Well some day we may want to do X so I'll go ahead and add Y and Z to this feature in case we need to support it ..." If a good programmer doesn't need something now they do not add it. You never know what you will really need in the future. Stuff changes and writing stuff takes time now and support time later.
They also do a lot of things:
They have a mental map/design of the project in their head. Before a drop of code hits the computer a top programmer already has a picture of what it will look like. Just like an artist has imagined their canvas before they have touched the paint a programmer has designed something in their mind. It may be designed in components as they go but they don't start writing blindly with out a mental map. They are working on the project a lot more often then most people notice. Taking a shower, falling asleep, occasionally driving a car, they are architecting their code in their head. The mental map in the above point is evolving all the time. A good programmer in the middle of thinking out a project in the beginning may have a lot in common with an absent minded professor. They test their work as they go. Even a genius will make mistakes. In fact I'd argue a top programmer accepts that mistakes are human and works in a manner where they expect them. They test the components as they build the project. They make sure the beam is strong before the building rests its weight on it. Sometimes they will look slower then others but when they are done there will be a solid master piece. They reference a mental library of experience. Reading and following this or any list will not automatically turn someone into a top programmer. A brilliant mind does not automatically make someone a top programmer. 30 years at the same job will not make someone a top programmer. Top programmers have coded a lot. They have coded in different languages. They have coded on different projects and at different companies. In the back of their head is a natural library of a million things that work and don't work. A million patterns for how things are done in different places. They probably don't realize it but as they work the components they need are built out of this vast experience.
翻譯練習: 首先,他們不會做某些事情:
他們不會重複發明輪子。有太多的事情值得去做,而不應該把時間都浪費到一些別人已經做的很好的事情上。如果已經有現成的庫、組件、程式碼片段或是例子什麼的,他們會欣然使用這些有用的東西,而將時間花費在新的東西上。 他們不會寫現在用不上的代碼。換句話說,他們會盡量使用最簡單的方法解決問題。在編寫一些東西時,這樣的想法也會很普遍“有一天我可能會在做X,所以我會繼續把Y和Z也順帶著一起做了,以防不時之需……”。但要是一個優秀的程式員,如果現在不需要的東西,他是不會加上的。你永遠不會知道未來的需求是什麼。應該把經曆集中在模組目前的變化和編寫,而把重構留在將來去解決。
當然,他們會做很多事:
他們會在大腦中構建項目的草圖和設計圖。在開始敲代碼之前,頂級程式員應該在大腦中建立起一個清晰的結構圖。就像一位畫家會先想象作品在畫布上的模樣才會去動筆作畫,頂級程式員會先在大腦中畫出設計草圖。It may be designed in components as they go,但是他們不會在還沒有想清楚的情況下就動手編寫代碼。 他們思考的時候別人也許無法察覺到他們正在思考。在洗澡的時候,小睡的時候,開車的時候,他們都在大腦中構思著設計,他們大腦中的草圖會在這些時候一點一點得變得清晰。當你面前的優秀程式員開始沉浸于思考時會表現的像是一位心不在焉的專家。 他們總是會做測試。即使是天才也會犯錯。當然,我所說的頂級程式員能接受的錯誤是人員和操作正常時卻沒有得到期望結果的錯誤。他們在測試模組時就想在修建一個建築,他們要確保房梁足以承受預期的重量。有時候他們會比其他的程式員效率低,但是一單模組完成,將是堅固可靠的傑作。 他們把大腦中的知識轉化成經驗。越多或是關注一個郵件清單不會讓人自動成為頂級程式員。在一個崗位幹上30年也不會成為頂級程式員。頂級程式員需要編寫大量的代碼,並且用不同的語言編寫代碼,他們會編寫不同的項目或模組。在他們的大腦中深處,有一個天然的庫儲存著成千上萬的行得通或行不通的例子,也會有成千上萬的不同環境下行得通的經驗。他們可能沒有察覺到這點,但當他們工作時,所依賴的就是這些豐富的經驗。 (完)