日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

开发人员避免编写测试的2个最常见原因

發(fā)布時間:2023/11/29 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 开发人员避免编写测试的2个最常见原因 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

This post was originally published on Medium

這篇文章最初發(fā)表于Medium

Writing tests represents one of those few stages of software development that is usually overlooked, even though it may be one of the most important one. Developers mention it and usually are either uncomfortable and prefer not to write tests for their code, or have many excuses for not writing them at all.

編寫測試代表了通常被忽略的那幾個軟件開發(fā)階段之一,盡管它可能是最重要的階段之一。 開發(fā)人員會提到它,通常會感到不舒服,他們不愿意為他們的代碼編寫測試,或者有很多借口根本不編寫代碼。

Well, tests are important:

好吧,測試很重要:

  • A software bug in a Therac-25 radiation therapy machine caused the death of five patients after receiving a massive dose of X-rays.

    Therac-25放射治療機中的軟件錯誤在接受大量X射線照射后導(dǎo)致五名患者死亡。

  • Knight Capital lost half a billion dollars in half an hour when a software bug allowed computers to sell and buy millions of shares with no human oversight.

    騎士資本(Knight Capital)在半小時內(nèi)損失了10億美元,當(dāng)時一個軟件漏洞允許計算機在無人監(jiān)督的情況下買賣計算機。

These and many other stories tell how seemingly unimportant bugs can actually cause so many tragic disasters.

這些故事以及其他許多故事都說明,看似不重要的錯誤實際上會導(dǎo)致如此多的悲劇性災(zāi)難。

We know how critical software is becoming to every area of our lives. We know that the security, stability and correctness of this software has a crucial importance in our lives. So the question is: why do developers still avoid writing tests?

我們知道關(guān)鍵軟件在我們生活的各個領(lǐng)域都變得越來越重要。 我們知道,該軟件的安全性,穩(wěn)定性和正確性對我們的生活至關(guān)重要。 所以問題是:為什么開發(fā)人員仍然避免編寫測試?

借口1:“筆試只會花太多時間。” (Excuse #1: “Writing tests just takes too much time.”)

It’s easy to perceive writing tests as taking too much time, as opposed to jumping directly into the implementation part.

很容易將編寫測試視為花費大量時間,而不是直接跳到實現(xiàn)部分。

This may be true in the short term, but if we take into consideration the time you may potentially need to fix all the bugs you could avoided by writing tests, then writing tests can actually save time — and even money — along the way.

在短期內(nèi)這可能是正確的,但是如果考慮到時間,您可能需要修復(fù)通過編寫測試可以避免的所有錯誤,那么編寫測試實際上可以節(jié)省時間,甚至節(jié)省金錢。

Tests do not eliminate bugs completely (nothing can do that), but they can dramatically reduce them. They can even make you feel more confident that you’re not breaking any existing functionality when you add new features and refactor old ones.

測試不能完全消除錯誤(沒有辦法做到),但是可以大大減少錯誤。 它們甚至可以使您更有信心,在添加新功能并重構(gòu)舊功能時不會破壞任何現(xiàn)有功能。

Tests also help you save time and protect your existing implementations from inexperienced programmers who recently joined your team. If these newcomers introduce bugs, your tests will fail. And when your tests fail, you become aware that something went wrong.

測試還可以幫助您節(jié)省時間,并保護您的現(xiàn)有實現(xiàn)免受最近沒有經(jīng)驗的程序員(加入您的團隊)的侵害。 如果這些新手引入了錯誤,則您的測試將失敗。 當(dāng)測試失敗時,您會意識到出了點問題。

Project managers who lack a programming background — and thus may not understand the programming complexities that may arise all of a sudden — tend to have high expectations of the developers on their teams. They want to things done quickly, and fast production-ready code. They may consider it unreasonable to postpone a strict deadline.

缺乏編程背景的項目經(jīng)理(因此可能無法理解突然出現(xiàn)的編程復(fù)雜性)往往對團隊中的開發(fā)人員抱有很高的期望。 他們希望快速完成事情,并快速準(zhǔn)備生產(chǎn)代碼。 他們可能認(rèn)為推遲嚴(yán)格的截止日期是不合理的。

These situations may put you into tough situations — where you have to choose between following best practices or getting things done quick-and-dirty.

這些情況可能會使您陷入困境–在這種情況下,您必須選擇遵循最佳實踐或快速完成工作。

You should try and find a few professional principles you can stick to no matter what. You should try your best to convince your manager of the importance of best practices, and how they pay off in the long run. And if your manager can’t be convinced, then you may consider changing jobs.

您應(yīng)該嘗試找到一些無論如何都可以堅持的專業(yè)原則。 您應(yīng)該盡力使您的經(jīng)理相信最佳做法的重要性,以及從長遠來看它們?nèi)绾萎a(chǎn)生收益。 而且,如果無法說服您的經(jīng)理,那么您可以考慮換工作。

借口2:害怕編寫測試 (Excuse #2: the fear of writing tests)

It’s no surprise that developers spend most of their working hours either reading code, writing code, or discussing new problems to solve with code. As a result, they have a very strong emotional attachment to it, and prefer to treat it as their precious property.

開發(fā)人員將大部分工作時間花費在閱讀代碼,編寫代碼或討論要用代碼解決的新問題上也就不足為奇了。 結(jié)果,他們對它有著強烈的情感依戀,并喜歡將其視為自己的寶貴財產(chǎn)。

Many are confident that they’re already experienced enough, and that they are capable of covering every possible scenario without much effort.

許多人相信自己已經(jīng)有足夠的經(jīng)驗,并且能夠輕松應(yīng)對各種可能的情況。

On the inside, they may harbor a sense of insecurity. And subjecting their code to tests may cause that insecurity to flare up.

在內(nèi)部,他們可能懷有不安全感。 對他們的代碼進行測試可能會導(dǎo)致這種不安全感加劇。

Maybe they pushed their code changes to the master branch faster than they should have, because they want to look like a productive employee to their manager. And now they’re afraid that writing tests might reveal bugs in their code. They’re afraid of being exposed as average programmers who cannot write bug-free code.

也許他們將代碼更改推送到master分支的速度比他們應(yīng)有的速度快,因為他們希望在經(jīng)理中看起來像是富有成效的員工。 現(xiàn)在,他們擔(dān)心編寫測試可能會發(fā)現(xiàn)其代碼中的錯誤。 他們害怕被無法編寫無錯誤代碼的普通程序員所接受。

Well, we should all do ourself a favor and never let our own sense of ego delude us into not writing tests. As uncomfortable as it may feel, we should take responsibility for our own work. This is one of the best ways to avoid bugs — bugs which can often have tragic consequences.

好吧,我們都應(yīng)該幫自己一個忙,不要讓我們自己的自我意識欺騙我們不編寫測試。 盡管感覺不舒服,我們應(yīng)該為自己的工作負(fù)責(zé)。 這是避免bug的最佳方法之一,而bug往往會帶來悲劇性的后果。

Tests allow you to make big changes in your code quickly, since you can be confident that everything is working correctly. When you’re used to writing tests for your code, you will then usually be able to finish off your work a lot faster, as you will have instant visual feedback when something is failing as you will see a red light. As a result, you will also write better code, feel less stress, and eventually get promoted, as you’re ultimately bringing in more value with the work that you are doing.

測試使您可以快速地對代碼進行重大更改,因為您可以確信一切正常。 當(dāng)您習(xí)慣于為代碼編寫測試時,通常可以更快地完成工作,因為當(dāng)出現(xiàn)故障時您會立即獲得視覺反饋,因為您會看到紅燈。 結(jié)果,您還將編寫更好的代碼,減輕壓力,并最終獲得晉升,因為您最終將通過所做的工作帶來更多價值。

抽出時間進行測試 (Make time for testing)

Tests will never be able to catch 100% of bugs, but they will contribute to the security, stability and correctness of your code. Make time for them.

測試將永遠無法捕獲100%的錯誤,但是它們將有助于代碼的安全性,穩(wěn)定性和正確性。 為他們騰出時間。

This post was originally published on Medium

這篇文章最初發(fā)表于Medium

翻譯自: https://www.freecodecamp.org/news/2-most-frequent-reasons-why-developers-avoid-writing-tests-e13fc74ee2ab/

總結(jié)

以上是生活随笔為你收集整理的开发人员避免编写测试的2个最常见原因的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。