I've been programming since I was 11 and I've loved technology and
programming every since. There are some hard and easy lessons I've learned over
time. As a fellow programmer, you may not have experienced these, but I'm
offering them to individuals who are interested in learning more from my
experiences.
I'll be updating this as time goes on. I may have more, but in my 20 year
period, I don't think there are any additional rules that this list doesn't
include.
Here are my most memorable lessons so far.
- Set a duration of how long you think it should take to solve a
problem - C'mon, admit it! I'm just as guilty as the next programmer.
I've seen programmers sit in front of a monitor for eight hours at a time trying
to solve a particular problem. Set a time table for yourself of 1 hour, 30
minutes, or even 15 minutes. If you can't figure out a solution to your problem
within your time frame, ask for help or research your problem on the Internet
instead of trying to be super-coder.
- A language is a language is a language - Over time, once
you understand how one language works, you'll notice similarities between other
languages. The language you choose should provide you with a suitable "comfort"
level, the ability to produce efficient (and clean) code, and, above all, allow
the language to suit the project and vice-versa.
- Don't over-"design pattern" applications - Sometimes it's
just easier to write a simple algorithm than it is to incorporate a singleton or
facade pattern. For the most part, it even allows for cleaner, understandable
code.
- Always backup your code - I've experienced a complete hard
drive failue and lost a lot of code when I was younger and felt horrible because
of what had happened. The one time you don't back up your data may be the one
time where you have a strict deadline with a client and they need it tomorrow.
Source code/version control applies here as well.
- You are not the best at programming. Live with it. - I
always thought that I knew so much about programming, but there is always
someone out there better than you. Always. Learn from them.
- Learn to learn more - With number five explained, I've
always had a magazine or book in my hand about computers or programming (ask my
friends, they'll confirm). True, there is a lot of technology out there and
keeping up with it is a fulltime job, but if you have a smart way of receiving
your news, you'll learn about new technology every single day.
- Change is constant - Your knowledge of technology and/or
programming should be similar to how you treat stocks: Diversify. Don't get too
comfortable with a particular technology. If there's not enough support for that
language or technology, you might as well start updating your resume now and
start your training period. My general rule of thumb that has kept me going?
Know at least two or three languages, so if one dies off, you have another one
to fall back on while you train for a new technology.
- Support Junior - Assist and train the junior/entry-level
developers on good programming guidelines and techniques. You never know...you
may move up in rank and you'll feel more confident having personally trained and
prepared them for their next position.
- Simplify the algorithm - Code like a fiend, but once you're
done, go back through your code and optimize it. A little code improvement here
and there will make support happier in the long run.
- Document your code - Whether its documenting a Web Service
API or documenting a simple class, document as you go. I've been accused of
over-commenting my code and that's something I'm proud of. It only takes a
second to add an additional comment line for each 3 lines of code. If it's a
harder technique to grasp, don't be afraid to over-comment. This is one problem
most architects, backup coders, and support groups don't complain about if
you've done your job right.
- Test, Test, Test - I'm a fan of Black Box Testing.
When your routine is finished, your "stamp of approval" period starts. If you
have a Quality Assurance department, you may be talking more to them than your
project manager regarding errors in your code. If you don't test your code
thoroughly, you may develop more than code. Possibly a bad reputation.
- Celebrate every success - I've met a lot of programmers who
have conquered headache-style problems with a great programming technique and
celebrated with a fellow programmer by doing the "shake", the high-five, or even
a "happy dance." Everyone has enlightening periods in their life and even though
that one happy coder asked you to come and see his extraordinary piece of code
and you've seen that one piece of code over 100 times in your experiences,
celebrate the success of a fellow developer for the 101-st time.
- Have Code Reviews Frequently - On projects and personally.
In the company, you will always have code reviews of how well you coded
something. Don't look at it as people crucifying your coding style. Think of it
as constructive criticism. On the personal front, review your code and always
ask, "How could I have done it better?" This will accelerate your learning and
make you a better programmer.
- Reminisce about your code - There are two
ways to looking at old code: "I can't believe I wrote this code" and "I can't
believe I wrote this code." The first statement is often of disgust and
wondering how you can improve it. You'd be surprised at how old code can be
resurrected into a possible and better routine, or maybe even an entire product.
The second statement is of amazement and achievement. Developers have their one
or two project code achievements that they completed and had everyone standing
up and taking notice. Again, based on your excellent coding ability, you could
take those past routines or projects and update them into a better product or
idea.
- Humor is necessary - In my 20 years of development, I have
never met a programmer who hasn't had a decent sense of humor. Actually, in this
industry, it's a requirement.
- Beware the know-it-all, possessive coder, and the inexperienced
coder - Humble yourself when you meet these types of coders. The
know-it-all tries to upstage you instead of working as a team player, the
defensive coder created code that he doesn't want to share with anyone, and the
inexperienced coder constantly asks for assistance every ten minutes where the
finished code developed is yours, not theirs.
- No project is ever simple - I've been asked by friends,
family, and associates to just "whip something up for me." To "whip" up a
program or web site, it takes planning from both parties to complete something
that both sides can appreciate. If someone needs a 3-page web site with
Microsoft Access from the start, it winds up becoming a 15-page web site with
SQL Server, a forum, and a custom CMS (Content Management System).
- Never take anything for granted - If you take on a simple
project, you may think that a certain section will be easy to complete. Don't
think that even for a moment. Unless you have a class, component, or piece of
code already coded...and has been tested thoroughly...and is in
production from an existing project, don't think it will be easy.
- Software is never finished - A fellow programmer once told
me that software is never finished, it's "temporarily completed." Sound advice.
If the client is still using a program you wrote and has stood the test of time,
chances are, you are still updating it, which isn't a bad thing. It keeps you
working.
- Patience is definitely a virtue - When clients, friends, or
family members use a PC, they get frustrated and proceed to hit a component of
the PC or storm off. I keep telling everyone, "you are controlling the computer
not the other way around." You need to have a certain level of patience for
programming computers. As soon as programmers understand what they did wrong,
they look at it from the computers point of view and say, "Oh, that's why it was
doing that."
I hope this list of lessons learned have either inspired or provided a
chuckle for some people.
從11歲時,我就一直在編程,並且一直都很喜歡技術和編程。這些年來,我積累了一些艱難又容易的經驗。作為一名程式員,你或許還沒這些經驗,但我會把它們獻給那些想從中學到更多的朋友。
我會持續更新這些經驗,我可能還會有更多的感想,但就我這20年來看,我想下面這個列表中基本不需要增添額外的東西了。下面就是我至今最難忘的經驗。
1.
估算解決問題所需要的時間。不要怕,承認吧!我曾見過一些程式員為瞭解決一個特殊問題而坐在顯示器前面8小時。為自己定一個時間限制吧,1小時、30分鐘或甚至15分鐘。如果在這期間你不能解決問題,那就去尋求協助,或到網上找答案,而不是嘗試去做“超級堆碼員”。
2. 程式設計語言是一種語言,只是一種語言。隨著時光推移,只要你理解了一種語言的原理,你會發現各種語言之間的相似之處
。你所選擇的語言,你應該覺得“舒服”,並且能夠寫出有效(而且簡潔)的代碼。最重要的,讓語言去適應項目,反之亦然。
3.
不要過於注重程式的“設計模式”。 有時候,寫一個簡單的演算法,要比引入某種模式更容易。在多數情況下,程式碼應是簡單易懂,甚至清潔工也能看懂。
4.
經常備份代碼。在我年輕時,我就有過因硬碟故障而丟了大量代碼的經曆,這經曆很恐怖的。只要你一次沒有備份,就應當像有著嚴格的期限,客戶明天就需要。此時就該源碼/版本控制軟體大顯身手了。
5. 承認自己並不是最頂尖的程式員 -
知不足。我常想,我對編程瞭解已足夠多,但是總有其他人比你優秀。正所謂,“一山總比一山高”。所以,向他們看齊吧!
6.
學習再學習。正如第5點所說,我經常會在手裡拿一本電腦或編程相關的雜誌或書(不信,可以問我的朋友)。誠然,總有很多你不知道的技術,你可以從中學習以保持不落後。如果你有一種靈巧的方式來擷取你需要的新技術,那你每天都應該堅持學習。
7.
永恒的變化。你對待技術/編程知識,就應像你對待股票一樣:多樣化。不要在某一特定技術上自我感覺良好。如果那種技術或語言已經沒有足夠支援,那你還不如現在就開始更新你的簡曆,並啟動培訓新計劃。我能保持前行的主要原則是什麼呢?至少瞭解兩到三種語言,所以,如果某種語言過時了,你在學習新技術的時候還可以依靠另一種語言。
8.
提攜新人。協助並且培養初級/入門的開發人員學習優秀的編程方法和技巧。也許你還不知道,在協助他們向更高一層前進時,你自己也在向更高一層提升,你會更加自信。
9. 簡化演算法。代碼如惡魔,在你完成編碼後,應回頭並且最佳化它。從長遠來看,這裡或那裡一些的改進,會讓後來的技術服務人員更加輕鬆。
10.
編寫文檔。無論是Web服務的API,還是一個簡單的類,你盡量編寫相應文檔。我曾經引以為豪的代碼注釋,因過度注釋而有人指責。給三行代碼加一行注釋,只需要你幾秒時間。如果那是一個比較難以理解的技術,千萬別擔心過多注釋。如果你能很好做好自己的工作,大多數架構師、後備程式員、支援組都會感激你。
11.
測試、測試再測試。我是一名黑箱測試粉絲。當你完成編碼後,你“被認可”的時候就開始了。如果你們公司有QA部門,如果你的代碼中有錯誤,那你得到的評論,會比專案經理還多。如果你不徹底測試自己的代碼,那恐怕你開發的就不只是代碼,可能還會聲名狼藉。
12.
慶祝每一次成功。我見過很多程式員在解決編程技術難題後,會和同伴握手、擊掌或甚至手舞足蹈。每個人在生命中都會碰到“頓悟”。如果一個程式員高興地跑來叫你去看他的非凡代碼,也許你已經看過這樣的代碼100遍了,但你也應該為了這個傢伙而慶祝第101次。
13.
經常檢查代碼。 在公司,你的代碼要經常檢查(包括自查和其他同事檢查)。不要把別人的檢查,看成是對代碼風格的苛求。應該把它們看作是有建設性的批評。對個人來說,經常檢查你的代碼並且自問,“我怎樣才能寫得更好呢?”
這會讓你加速你的成長,讓你成為一個更優秀的程式員。
14.
回顧你的代碼。在看到自己以前的代碼時,通常會有兩種方式:“難以至信,這代碼是我寫的”和“難以至信,這代碼是我寫的”。第一種往往是厭惡的語氣,並在想如何改進它。你也許會驚歎,舊代碼也能複活成為一種更好的程式,甚至是一個完整的產品。第二種通常帶著驚奇和成就感。開發人員應該一到兩個自己完成的項目成果,能讓眾人不禁而立並注目而觀的項目。同樣,基於你優越的編程能力,你可以把過去的程式或項目拿出來,把它們更新為更加優秀的產品或想法。
15. 幽默是不可缺的。在我20年的開發生涯中,我還沒有碰到哪位程式員是沒有幽默感的。實際上,幹我們這行,幽默是一項必備品。
16.
謹防那些無所不知的程式員,不願分享的程式員,還有經驗不足的程式員。當你遇到這幾種程式員時,你自己要謙虛。無所不知的程式員,更想當一個英雄而不是團隊成員;保守的程式員則是在編寫著他們獨享的代碼;而經驗不足的程式員則會每十分鐘就來問你一下,當程式碼完成後,代碼已經是你的,而不是他們。
17.
任何項目都不會那麼簡單。朋友、家人和同事曾請求我倉促做一些事情,倉促做一個程式或者網站。對於這樣的事,應該從雙方做計劃,才能做出令兩方都會滿意的東西。如果某人起初只是需要一個使用Microsoft
Access的、只有有3個頁面的網站,但來就很可能變成一個有15個頁面的網站,並使用SQL
Server,有一個論壇,還有一個定製的CMS(內容管理系統)。
18.
任何時候不要想當然。假如你承接一個簡單的項目,你可能會認為某個部分可以輕鬆完成。千萬別這樣想!除非你有一個類、組件、或者一段已經寫好的代碼,並且在現有的項目已經測試通過。不要認為這將是很容易的。
19.
沒有已經完成的軟體。曾經有一位程式員告訴我,沒有軟體是已經完成的,它只是“暫時完成了”。這是明智的忠告。如果客戶還在使用你寫的程式,並經受了時間的考驗。如果有機會,你仍在更新它,這並不是什麼壞事,這讓你不斷地前行。
20.
耐心是一種美德。當客戶、朋友或家庭成員用電腦的時候,他們也許會受挫,進而想砸電腦,或氣沖沖地離開。我一直在告訴他們,“是你掌控電腦,不是電腦掌控你。”對於用作編程的電腦,你要有一定的耐心。一旦程式員知道問題所在後,他們就會站在電腦的角度看問題,並且說“哦,這就是為什麼它是這樣做。”
本文轉自:http://www.jobbole.com/entry.php/322
英文出自:http://www.dcs-media.com/Archive/20-20-top-20-programming-lessons-ive-learned-in-20-years-FH