混亂的代碼是技術(shù)債嗎

翻譯自 Uncle Bob 的 Blog A Mess is not a Technical Debt
主要是鮑勃大叔的觀點(diǎn):混亂的代碼實(shí)現(xiàn)不是技術(shù)債蛹头。原文地址見(jiàn)超鏈接顿肺。


The term Technical Debt was created by Ward Cunningham to describe the engineering trade-off’s that software developers and business stakeholders must often make in order to meet schedules and customer expectations. In short, you may need to use suboptimal designs in the short term, because the schedule does not allow longer term designs to be used. As a simple example, your initial website design may need to be frames based because you don’t have time to build an Ajax framework.

技術(shù)債務(wù)一詞由 Ward Cunningham 提出,用于描述軟件開(kāi)發(fā)人員和業(yè)務(wù)利益相關(guān)者必須經(jīng)常做出的工程權(quán)衡渣蜗,以滿(mǎn)足交付進(jìn)度和客戶(hù)期望屠尊。 簡(jiǎn)而言之,可能需要在短期內(nèi)使用次優(yōu)設(shè)計(jì)耕拷,因?yàn)闀r(shí)間表不允許使用長(zhǎng)期設(shè)計(jì)知染。 舉個(gè)簡(jiǎn)單的例子,您的初始網(wǎng)站設(shè)計(jì)可能需要基于框架(frames based)斑胜,因?yàn)槟鷽](méi)有時(shí)間構(gòu)建 Ajax 框架。

Clearly this causes a debt. If the customer is looking for a web 2.0 system, then frames just aren’t going to cut it for long. So time is going to have to be carved out of a future schedule to refit the system with an Ajax solution.

顯然嫌吠,這會(huì)導(dǎo)致債務(wù)止潘。如果客戶(hù)正在尋找一個(gè) web 2.0 系統(tǒng),那么框架就不會(huì)長(zhǎng)期削減它辫诅。因此凭戴,必須從未來(lái)的計(jì)劃中抽出時(shí)間來(lái)用 Ajax 解決方案改造系統(tǒng)。

In short, the business has decided that it can afford to delay release 2 in order to accelerate release 1. Is this wise?

簡(jiǎn)而言之炕矮,企業(yè)已經(jīng)決定延遲發(fā)布版本 2 以加速發(fā)布版本 1么夫。這是明智的嗎?

Businesses make this kind of trade-off all the time; and there’s nothing inherently unwise about it. If the early release of 1.0 drives the business that pays for the development of 2.0 then the business has won. So this kind of reasoned technical debt may indeed be appropriate.

企業(yè)一直在進(jìn)行這種權(quán)衡肤视;它本身并沒(méi)有什么不明智的档痪。如果 1.0 的早期發(fā)布推動(dòng)了為 2.0 的開(kāi)發(fā)買(mǎi)單的企業(yè),那么企業(yè)就贏了邢滑。所以這種合理的技術(shù)債可能確實(shí)是合適的腐螟。

Unfortunately there is another situation that is sometimes called “technical debt” but that is neither reasoned nor wise. A mess.

不幸的是,還有另一種情況有時(shí)被稱(chēng)為“技術(shù)債”困后,但這既不合理也不明智乐纸。一一一團(tuán)混亂的代碼。

Technical debt may be necessary, but it had also better be clean! If you are going to implement a frames solution instead of an AJAX solution, then make sure that the workmanship of the frames solution is top-notch. Make sure the design is well balanced, and the code is clean. If you make a mess while implementing that frames solution, you’ll never be able to replace it with an AJAX framework. The mess will impede your progress forever.

技術(shù)債務(wù)可能是必要的摇予,但它也最好是整潔的汽绢!如果您要實(shí)現(xiàn)框架解決方案而不是AJAX 解決方案,那么請(qǐng)確辈啻鳎框架解決方案的工藝是一流的宁昭。確保設(shè)計(jì)平衡良好跌宛,代碼整潔。如果您在實(shí)現(xiàn)該框架解決方案時(shí)弄得一團(tuán)糟久窟,您將永遠(yuǎn)無(wú)法用AJAX框架替換它秩冈。混亂將永遠(yuǎn)阻礙你的進(jìn)步斥扛。

A mess is not a technical debt. A mess is just a mess. Technical debt decisions are made based on real project constraints. They are risky, but they can be beneficial. The decision to make a mess is never rational, is always based on laziness and unprofessionalism, and has no chance of paying of in the future. A mess is always a loss.

混亂的代碼實(shí)現(xiàn)不是技術(shù)債入问。混亂的實(shí)現(xiàn)只是一團(tuán)糟糕的代碼稀颁。技術(shù)債務(wù)決策是根據(jù)實(shí)際項(xiàng)目限制做出的芬失。它們是有風(fēng)險(xiǎn)的,但它們可能是(對(duì)項(xiàng)目)有益的匾灶。讓編碼混亂的行為永遠(yuǎn)是不理智的棱烂,它永遠(yuǎn)都是因?yàn)?開(kāi)發(fā)者)懶惰和不專(zhuān)業(yè)造成的,而且將來(lái)你也永遠(yuǎn)還不清這種債務(wù)阶女〖彰樱混亂永遠(yuǎn)都是一種錯(cuò)誤……

When you buy a house and take on a big mortgage debt, you tighten up all your spending and accounting. You clean up your books and your budgets. You behave with increased discipline. The same is true of technical debt. The more technical debt you take on, the tighter your disciplines need to be. You should do more testing, and more pairing and more refactoring. Technical debt is not a license to make a mess. Technical debt creates the need for even greater cleanliness.

當(dāng)您購(gòu)買(mǎi)房屋并承擔(dān)巨額抵押貸款時(shí),您會(huì)收緊所有支出和賬戶(hù)消費(fèi)秃踩。你清理你的訂單和你的預(yù)算衬鱼,你表現(xiàn)得更加自律。技術(shù)債務(wù)也是如此憔杨。你承擔(dān)的技術(shù)債務(wù)越多鸟赫,你收緊得就應(yīng)該越嚴(yán)格。你應(yīng)該做更多的測(cè)試消别,更多的結(jié)對(duì)編程和更多的重構(gòu)抛蚤。技術(shù)債務(wù)不是制造混亂的許可證。技術(shù)債務(wù)創(chuàng)造了對(duì)更高整潔度的需求寻狂。

When you decide to take on a technical debt, you had better make sure that your code stays squeaky clean. Keeping the system clean is the only way you will pay down that debt.

當(dāng)您決定承擔(dān)技術(shù)債務(wù)時(shí)岁经,您最好確保您的代碼保持干凈整潔。保持系統(tǒng)清潔是償還債務(wù)的唯一方法蛇券。


本文首發(fā)于公眾號(hào) 架構(gòu)道與術(shù)(ToBeArchitecturer)蒿偎,歡迎關(guān)注、學(xué)習(xí)更多干貨~

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末怀读,一起剝皮案震驚了整個(gè)濱河市诉位,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌菜枷,老刑警劉巖苍糠,帶你破解...
    沈念sama閱讀 218,682評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異啤誊,居然都是意外死亡岳瞭,警方通過(guò)查閱死者的電腦和手機(jī)拥娄,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)瞳筏,“玉大人稚瘾,你說(shuō)我怎么就攤上這事∫唬” “怎么了摊欠?”我有些...
    開(kāi)封第一講書(shū)人閱讀 165,083評(píng)論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)柱宦。 經(jīng)常有香客問(wèn)我些椒,道長(zhǎng),這世上最難降的妖魔是什么掸刊? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,763評(píng)論 1 295
  • 正文 為了忘掉前任免糕,我火速辦了婚禮,結(jié)果婚禮上忧侧,老公的妹妹穿的比我還像新娘石窑。我一直安慰自己,他們只是感情好蚓炬,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,785評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布松逊。 她就那樣靜靜地躺著,像睡著了一般试吁。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上楼咳,一...
    開(kāi)封第一講書(shū)人閱讀 51,624評(píng)論 1 305
  • 那天熄捍,我揣著相機(jī)與錄音,去河邊找鬼母怜。 笑死余耽,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的苹熏。 我是一名探鬼主播碟贾,決...
    沈念sama閱讀 40,358評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼轨域!你這毒婦竟也來(lái)了袱耽?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,261評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤干发,失蹤者是張志新(化名)和其女友劉穎朱巨,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體枉长,經(jīng)...
    沈念sama閱讀 45,722評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡冀续,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,900評(píng)論 3 336
  • 正文 我和宋清朗相戀三年琼讽,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片洪唐。...
    茶點(diǎn)故事閱讀 40,030評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡钻蹬,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出凭需,到底是詐尸還是另有隱情问欠,我是刑警寧澤,帶...
    沈念sama閱讀 35,737評(píng)論 5 346
  • 正文 年R本政府宣布功炮,位于F島的核電站溅潜,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏薪伏。R本人自食惡果不足惜滚澜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,360評(píng)論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望嫁怀。 院中可真熱鬧设捐,春花似錦、人聲如沸塘淑。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,941評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)存捺。三九已至槐沼,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間捌治,已是汗流浹背岗钩。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,057評(píng)論 1 270
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留肖油,地道東北人兼吓。 一個(gè)月前我還...
    沈念sama閱讀 48,237評(píng)論 3 371
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像森枪,于是被迫代替她去往敵國(guó)和親视搏。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,976評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容