技術債,怎麼還?

{"type":"doc","content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"無論債務是怎樣累積起來的,你都必須償還。"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic"},{"type":"color","attrs":{"color":"#333333","name":"user"}},{"type":"strong"}],"text":"本文最初發佈於"},{"type":"text","marks":[{"type":"italic"},{"type":"strong"}],"text":"Kyle Brown的個人"},{"type":"text","marks":[{"type":"italic"},{"type":"color","attrs":{"color":"#333333","name":"user"}},{"type":"strong"}],"text":"博客,經原作者授權由InfoQ中文站翻譯並分享。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"讓我們面對現實吧,2020年是奇怪的一年。其中有一個奇怪的小現象,自2012年以來,美國的個人儲蓄率首次出現增長(而且是以驚人的速度增長),而不是保持基本穩定[1]。雖然這其中大部分都與流行病有關,但這也許可以在一定程度上表明,消費者已經開始意識到,你不能一直借錢而不償還你所欠下的債務。我希望企業能夠意識到,同樣的原則也適用於技術債務,就像適用於金融債務一樣。這個類比可能會讓一些人覺得不太舒服,但這實際上是一個非常著名的思想,它最早是由Ward Cunningham在15年前提出[2],並由Joshua Kerievsky在2005年進一步發展[3]。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"簡單地說,當開發團隊爲了完成其他活動而放棄重要的軟件開發活動時,就會產生技術債務。通常,他們的想法是,他們會“回過頭去”完成這項活動,但意圖往往不會轉化爲活動。這類活動可能非常簡單,如編寫文檔,但也可能是更棘手的活動,比如修改一段代碼,讓它更容易理解和維護,或者是更新因爲代碼變化而過時的設計文檔。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"我最近在處理幾個客戶的問題,我感覺自己就像一個消費者債務顧問,在和一對揹負着鉅額抵押貸款的夫婦談話,他們的信用卡餘額在不斷增加,而且他們的孩子即將出生。在每一種情況下,我們都快要被技術債務壓垮了,我們必須找到一些方法來減少債務,同時繼續開發新功能並繼續前進。我提出了一套實踐方法,步驟和信貸顧問給他們客戶的建議類似。讓我們看看這些步驟,看看如何把他們應用於許多項目都面臨的技術債務狀況。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第一步:評估你的處境,弄清楚你欠了多少"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"這一步最關鍵。一旦團隊決定必須償還他們的技術債務(這不是一個容易的決定——而且必須與業務一起做出),他們就必須弄清楚他們實際上欠了多少債務。我發現,最好的方法是進行自上而下的設計和代碼審查。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"首先看看你的設計文檔。它是最新的嗎?它是否準確地描述了設計中最重要的點?然後,你可能想首先審查下代碼的哪些部分給你帶來了最大的麻煩——哪些部分最難修改?哪些地方出錯率最高?那些部分對你的業務來說最重要?找出這些問題的答案,可以幫助你對你需要做的事情進行排序,找出方法改善你的處境。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"系統中並不是只有代碼和文檔會導致技術債務。另一個需要考慮的關鍵因素是運營債務——例如,你是否運行在數據庫或應用程序服務器等平臺軟件構成的後臺上?你的運營團隊是否在手動執行應該自動化完成的任務,既浪費時間又浪費錢?你是否有適當的監控,以便在問題導致站點宕機之前發現問題,或者你是否把時間浪費在了事後分析上?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"通常,最好是請一個外部專家來幫助你評估項目狀態。引入一名外部人員讓你可以獲得一份純粹是基於解決方案技術優越性的評估,而不受辦公室政治或個人對某些代碼的情感所影響。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"最終的評估需要描述需要更改的內容,按照優先級進行排序,並提出代碼更改建議,以及列出的每個更改的估算成本。一旦你掌握了這些事實,你就可以開始與業務所有者協商你要償還哪些債務以及以什麼順序償還。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第二步:停止引入新債務"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"雖然上一步是整個計劃中最重要的一步,但第二步通常會導致與業務最針鋒相對的討論。其中最難的部分是學會組織文化變革,這樣你就不會讓積累的債務超過合理的服務能力。就拿我們的金融債務來說,這也是一件非常困難的事情——改變你的消費習慣,只買你需要的東西,而不是用信用卡購買你想要的東西,這是一件非常困難的事情。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"爲了修復發現的問題,你必須花時間來實現修復,這意味着你在糾正問題時會擱置新的開發。關於這一點,沒有什麼完美的方法,無論你採取什麼方法,你都需要與業務協商如何平衡技術債務償還和新功能開發。下面是一些我們認爲有效的策略。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"在用戶故事中包含債務償還活動。"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"如果前面的步驟已經形成了一組按大小分類並排好序的活動,那麼你可以與業務合作,確保在每個開發週期中都包含其中一部分活動。比較難的是平衡債務償還活動和涉及同一代碼區域的新功能開發。例如,如果你正在開發一個電子商務網站,並且你發現大多數問題都是發生在結帳時,你可能想要把涉及這一部分的新功能開發推遲到你償還該部分的技術債務時(例如,重構代碼或更新文檔)。在這種情況下,在更改的過程中添加新的促銷活動或更改產品頁面將是合理的選擇。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"採用貝塔測試。"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"如果你構建的基礎設施可以支撐兩個網站(一個是主網站,另一個是“測試”網站),那麼你可以在重構主代碼流的同時繼續在測試網站上開發新功能。這樣做的好處是不會減慢任何新功能開發的速度,但代價是,當對測試站點的更改必須重新集成到主站點時,集成難度會增加。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第三步:選擇債務償還策略"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"在這種情況下,我們可以和信用卡債務償還策略做個對比,考慮兩種不同的確定債務償還優先級的方法。第一種可能的策略是“最高利率優先”。在信貸領域,這種策略是先償還利率最高的信用卡,因爲這類信用卡支付的利息最高。在技術領域,這意味着你可以首先考慮承擔影響最大的任務。如果你解決了這些問題,通常就可以爲其他更改掃清障礙,並且可能在性能、可維護性等方面獲得最大的回報。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"另一種可能的策略是“最低餘額優先”策略。用信用卡的術語來說,這意味着先還清餘額最低的信用卡——事情很快就完成了,這會讓你立即獲得一種成就感。對於技術債務,一個類似的策略是首先處理最小的修復,如果你必須說服業務或管理人員償還技術債務,或者如果你所在的公司非常注重結果導向,只有快速取得進展才能爲更大的工作爭取到資金支持,這會特別有用。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第四步:按計劃行事!"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"這裏的關鍵是,讓償還債務成爲你長期活動的一部分。這不是一次性交易;對於“重構”[4]這類術語,人們不再像幾年前它開始流行時那樣抱有幻想,因爲他們希望最好是可以從長期投資中獲得短期結果。你總是會招致新的債務;關鍵是確保你能在合理的時間內償還,而不是讓它越積越多。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第五步:跟蹤和評估進展"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"最後,你需要能夠報告你在債務償還活動中取得的進展。採集一些指標,用於向管理和業務證明,花費在這些活動中的時間是值得的,這點特別重要。例如,很多時候你需要重構代碼來提高性能,這時,手上有正確的統計數據來顯示用戶體驗的改進是很重要的。同樣,當你在改進一個簡單的代碼庫時,添加新特性的速度是另一個向業務證明價值的重要指標。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"遵循這些步驟並不能解決技術債務相關的所有問題,但它們至少可以讓你係統性地確定需要做什麼,可以爲開發過程帶來什麼價值,以及變更在多大程度上解決了問題。如果你堅持這樣做,那麼這應該可以使你的開發工件更容易維護,並且應該可以減少你的開發壓力。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"參考資料"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"[1] "},{"type":"link","attrs":{"href":"https:\/\/fred.stlouisfed.org\/series\/PSAVERT","title":null,"type":null},"content":[{"type":"text","text":"https:\/\/fred.stlouisfed.org\/series\/PSAVERT"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"[2] Ward Cunningham,The Wycash Portfolio Management System,ACM SIGPLAN OOPS Messenger,April 1993"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"[3] Joshua Kerievsky,“Refactoring to Patterns”,Addison-Wesley,2005"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"[4] Martin Fowler,“Refactoring, Improving the Design of Existing Code”,Addison-Wesley,1999"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":" "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"查看英文原文"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":":"},{"type":"link","attrs":{"href":"https:\/\/kylegenebrown.medium.com\/paying-back-technical-debt-6038b0f27605","title":null,"type":null},"content":[{"type":"text","text":"Paying Back Technical Debt"}],"marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章