天天看點

程式員自我管理原則

blog.christoffer.me

Hi, my name is Christoffer and I am an Internet addict.

Saturday, November 26, 2011

9 things I learned from reading The Clean Coder by Robert C. Martin, on how professional developers conduct themselves

I recently finished reading  Robert C. Martins' latest book  The Clean Coder: A Code of Conduct for Professional Programmers (ISBN  0-13-708107-3).

Without hesitation, I can honestly say that this book has literally changed my view and thoughts on professional  software developers.

While reading this book, I have been writing notes in a scrap book on things I learned and things that turned on a light switch in my head. This entry is a compilation of those notes.

I strongly suggest that any, old or new, software developer that hasn't gotten the chance to read this book yet, should take the time and do it. It provides worthwhile and interesting information on what it means to be a professional software developer.

Disclaimer; Please note, as always different people interpret different things. This my interpretation of what is said in the book.

Update: After posting this blog entry, I have noticed it is getting quite a lot Reddit users with mixed feelings posting their comments and opinions. Some agree with these 9 points, while others don't. If you are into this stuff, it could be interesting to you to  read these Reddit comments as well. Maybe even letting your own voice be heard.

The 9 things I learned

  • A professional developer knows the domain of their project
  • A professional developer is a team player
  • A professional software developer takes responsibility
  • A professional developer knows patterns and disciplines
  • A professional developer remains calm during hectic situations
  • A professional developer keeps practicing their profession
  • A professional developer rests
  • A professional developer knows the value of time
  • A professional developer is never afraid to say no

1 - A professional developer knows the domain of their project

As a professional developer, your job is more than just reading requirement specifications and code the software. You should also know where and how the project is being used by the its users in the real world.

This means that if you are working on an  accounting software, you should at least have some basic knowledge about accounting. It is not necessary to become an expert in the subject, but a little knowledge helps a big way when solving problems and coming up with solutions.

2 - A professional developer is a team player

As a professional developer, you should of course be polite and helpful towards other people. When other people ask for help, you should treat them in the same manner as you wish someone would treat you, if you were stuck. You should always offer help and welcome help from others.

Also, you should not build a wall around yourself or your code. It is important to remember that you don’t own the code, but rather the team does. So instead of dismissing anyone from working in, or even seeing, the code, it should be encouraged. This will help you grow as a developer, since it opens up for feedback, but it also greatly benefits the group and the project itself.

Over time, teams slowly grows better and better as well, resulting in team members will eventually know each others strengths and weaknesses. When this happens the team becomes very efficient on solving issues as a group. Since it takes time to build up a solid team, when a project ends, it is smarter to give the team a new project, rather than disbanding the whole group.

3 - A professional software developer takes responsibility

As a professional developer, you take responsibility for your code. It is your job to know what your code does and know that all of the code works. When coding you should always aim to cause no harm in your project, by always aiming to get the error rate as close to zero as possible.

This is done by simple writing tests. Tested code gives you more confident about your work, knowing the fact that what deliver is at top class and checked against errors. Robert C. Martin repentantly says that a great goal is that the  QA department should never find bugs. An entire project with tested code also gives the developers more confident to actually do something about  smelly code.

Unit and  acceptance tests should be done automatically (due to it is significantly cheaper than manually testing) by using a continuous integration system. These tests should be running all the time, every time a developer commits code to the project. If a test breaks, it should be fixed as soon as possible.

Robert C. Martin is also strongly for  Test Driven Development. The TDD discipline forces the developer to think about good design and structuring up their code to make it test-friendly. According to Robert C. Martin, it is actually unprofessional not to use TDD.

4 - A professional developer knows patterns and disciplines

As a professional developer, it is your responsibility to write high-quality, tested, clean code. This includes knowing design patterns,  principles, methods, disciplines and  artifacts.

Since the software development industry is changing constantly with new ideas and tools around the next corner, it is also equally important that you keep yourself up to date on new disciples and techniques.

You should also never lower your standards by abandoning your disciplines, even in hectic and stressful situations just to cut time.

5 - A professional developer remains calm during hectic situations

As a professional developer, you should always remain calm during hectic and stressful situations. Instead, try and think out the best solution to resolve your situation and the inform your superiors about the situation and ask for their feedback and suggestions.

Acting on panic will most likely just result in making more errors. In emergencies, you could try and  pair program with a colleague. Not only will this probably decrease the number of new errors, but pair programming is also a great source of sharing knowledge between team members.

6 - A professional developer keeps practicing their profession

As a professional developer, you should spend time caring for your profession. Just like in any other profession, practice gives performance, skill and experience. 

It is your own responsibility to keep training yourself by reading, practicing and learning - actually anything that helps you grow as a software developer and helps you get on board with the constant industry changes.

An important note is this should be done on your own time, not on your employer's. It is not their responsibility to train you, but your own. However, do not mistake this with you should be doing your job during this time. This time should be dedicated for you and your own enjoyment only. You should do anything that interests you. According to Robert C. Martin, if you work 40 hours a week ,you should spend around 20 additional hours enhancing your own profession.

7 - A professional developer rests

As a professional developer, you should know that being a software developer is a very intellectual and exhausting job. It is important that you don’t  overwork yourself, but rather find a balance in life with your job. Being a well rested developer makes you more focused and makes you perform better at work. It also also a great receipt against  writer's block.

8 - A professional developer knows the value of time

As a professional developer, you should know the value of time. Your time is expensive and should not be wasted, meaning you should use your time wisely and know things like the the high  cost of meetings. Politely decline meetings that do not benefit you, or if your present doesn’t benefit anyone.

Meetings should also have a clear  agenda and a goal. If you notice that a meeting is getting boring and does not benefit you anymore, or if the agenda gets abandoned or if the meeting simple gets high-jacked, either request a new topic or politely leave the meeting. You probably have better things to do then remain seated.

9 - A professional developer is never afraid to say no

As a professional developer should not be afraid to say no. If you know something is unrealistic (such as an estimation, a deadline, a requirement, etc) it is expected from you to speak up. Not most of the time - but all the time.

You shouldn’t even say you can try, as that will give a false impression to everyone that the task is doable, and maybe even worse, it turns you into a liar which can hurt your reputation among your superiors and colleagues. Instead, try and rephrase yourself and explain your concerns. Be clear and specific about the problems and dates and times.

If your superiors refuses to listen to you and does not take no as an answer, you should think about going one step higher. Even though going over someones head might feel uncomfortable, in the end it will deliver the best possible outcome for all involved parties.

According to Robert C. Martin, the definition of an estimate is interpreted by different people. For business people, estimations are commitments. For software developers, estimations are guesses, measured in probability.

You should only do commitments, when you are certain it can be done. When professional commits to something, the provide with a hard number and makes certain the job before the deadline.

我最近剛讀完 Robert C. Martins 的新書 《The Clean Coder: A Code of Conduct for Professional Programmers 》(編注:暫無中文版)。我可以毫不猶豫地、誠實地說,這本書真的改變了我對于專業軟體開發人員的看法和觀念。在閱讀過程中,我一直把學習到的事情和頭腦中瞬間轉變的事情寫在剪貼簿上。

我強烈建議任何,不論老手或者新手,隻要是還沒有機會讀這本書的軟體開發人員都應該找時間讀一下。關于成為一名專業軟體開發人員的意義,這本書提供了許多有價值和有趣的資訊。

聲明:請注意,因為不同的人有不同的看法。這是我對這本書闡述内容的了解。

我學到的9件事

□ 一名專業開發人員了解所開發項目的領域

□ 一名專業開發人員是具有團隊精神的人

□ 一名專業軟體開發人員能肩負責任

□ 一名專業開發人員知道模式和準則

□ 一名專業開發人員能夠在忙碌中保持冷靜

□ 一名專業開發人員會不斷訓練自己的專業技能

□ 一名專業開發人員會适當休息

□ 一名專業開發人員懂得時間的寶貴

□ 一名專業開發人員從不害怕說不

1. 一名專業開發人員了解所開發項目的領域

作為一名專業開發人員,你的工作不僅僅是閱讀需求說明書和編寫軟體代碼。你還應該知道項目在現實中是如何使用的。

這就意味着如果你要編寫一個記賬軟體,你至少應該具備一些基本的财務知識。你不需要成為這個領域的專家,但是有一點這方面的知識的話,在解決問題和提出解決方案時将有很大幫助。

2.  一名專業開發人員是團隊的一員

作為一名專業開發人員,你當然應該對其他人禮貌并樂于助人。當别人向你尋求幫助時,你應該換位思考,像你自己所期望的那樣去幫助别人。你應該樂于助人并樂于接受别人的幫助。

而且,你不應該把自己和代碼獨立于團隊之外。記住!這些代碼不是屬于你的,是屬于整個團隊的。是以,不要不理會參與工作的其他人,甚至不讓他們看代碼,而是應該鼓勵。這将幫助你成長為一名開發人員,因為這樣就産生了回報,而這對團隊和項目都是大有裨益的。

團隊随着時間推移,也會變得越來越好,最後團隊成員會了解彼此的優點和弱點。當團隊能夠如此時,作為一個團隊就能很高效地解決問題了。由于需要時間來建立這樣堅實的團隊,當一個項目完成時,給團隊一個新項目比解散整個團隊要明智得多。

3.  一名專業軟體開發人員能肩負責任

作為一名專業開發人員,你要對你的代碼負責。你的工作就是了解你代碼的作用和所有代碼的功能。當你編碼時,你應該注意不要對你的項目産生危害,并且盡可能的将錯誤率降至接近于零。

這能夠通過簡單的測試完成。測試代碼使你對工作更有信心,了解怎樣編寫最好的代碼并且避免錯誤。Robert C. Martin最近說最高的目标是QA部門找不到任何小錯誤。一個具有測試代碼的完整項目也給開發人員更多的信心來處理漏洞。

單元測試和驗收測試應當利用持續內建系統自動完成(因為它比手動測試更加便宜)。這種測試應該一直運作,即使是開發人員向項目送出代碼的時候。如果測試間斷,應該盡快修複。

Robert C. Martin也強烈支援測試驅動開發。TDD緻力于訓練開發人員考慮更好的設計并建構他們的代碼,使之易于測試。據Robert C. Martin所說,不使用TDD是不專業的。

4.  一名專業開發人員了解模式和準則

作為一名專業開發人員,編寫高品質的、已測試的、幹淨的代碼是你的責任。這包括了解設計模式、規範、方法、準則和技巧。

由于軟體産業發展的不斷變化,不斷使用新的思路和工具,保持更新到最新的标準和技術同等重要。

你在任何時候都不能因為忽視标準而降低你的品質,即使是繁忙和緊張的情況下為了縮短時間。

5.  一名專業開發人員能夠在忙碌中保持冷靜

作為一名專業開發人員,你應該在忙碌和有壓力的情況下始終保持冷靜。嘗試想出最好的解決問題的辦法并将情況告知你的上司,尋求他們的回報和意見。

忙中更易出錯。在緊急情況下,你可以嘗試與同僚結對程式設計。這樣不僅可以減少新增的錯誤而且也是一個與團隊成員分享知識的好方法。

6.  一名專業開發人員會不斷訓練自己的專業技能

作為一名專業開發人員,你應該花時間關心你的技能。就像其他專業,實踐帶來能力、技巧和經驗。

通過讀、練和學習一直訓練你自己是你的責任——實際上,任何幫助你成長為軟體開發人員和幫助你起步的事物都在不停變化着。

重要的一點是,你應該在你自己的私人時間裡完成,而不是在工作時間裡。教育訓練你不是他們的責任,而是你自己的責任。當然,不要和你應該工作的時間弄錯。這個時間應該專門針對你和你的興趣。你可以做任何感興趣的事。據Robert C. Martin所說,如果你每周工作40小時,你應該花20小時提高你的專業技能。

7.  一名專業開發人員會适當休息

作為一名專業開發人員,你應該知道做一名軟體開發人員是很費腦子和累人的工作。注意不要勞累過度是很重要的,你需要在工作和生活之間尋找平衡。做一個休息好的開發人員使你能更專注并且在工作中表現得更好。這也是對抗心理阻滞的良方。

8.  一名專業開發人員懂得時間的寶貴

作為一名專業開發人員,你應該知道時間的寶貴。它們不應該被随意浪費,這就要求你要合理安排你的時間,比如開會,就很浪費時間。婉言謝絕會議對你不利,但如果參加則不利于任何人。

會議也應有明确的議程和目标。如果你注意到會議開始變得乏味并且對你不再有益,或者議程被放棄抑或會議變成簡單唱高調,你要麼換個新的話題要麼禮貌地離開。你也許有更好的事情去做而不是繼續坐在那裡。

9.  一名專業開發人員從不害怕說不

作為一名專業開發人員你不應該害怕說不。如果你發現一些事情是不現實的(例如一個意見、期限、要求等等)這些需要你提出來。不是大多數時候——而是每一次。

你甚至不應該說你可以試試,因為這樣将會提供一個假象那就是這個任務是可行的,也可能更糟,這使你變成一個騙子,有損你在上司和同僚之間的名聲。相反,嘗試改換措辭并解釋你所關心的問題。清晰和具體地明确問題的時間和日期。

如果你的上司不聽你的或者不接受否定的回答,你應該想想更進一步行動。雖然越級不太好,但是最後會帶來對所有參與者最好的結果。

據Robert C. Martin說,判斷的定義因人而異。對于商務人士,判斷方法是承諾。對軟體開發人員,判斷是猜測,機率計算。

你應該隻對能夠確定完成的工作做出承諾。當專業地對一些事承諾後,提供硬性标準并且確定在期限内完成工作。

繼續閱讀