022 TDD和Stack Overflow的专家开发者

2022-09-16 21:37:1212:31 35
所属专辑:敏捷理念
声音简介

Vanilla: Uh, you are Mr. Lecter, right?

 

Hannibai: Dr. Lecter.Just call me Hannibai.

 

Vanilla: Mr. Doctor, how does TDD work? Can we try to use it?

 

Hannibai: The process seems very simple, which is the opposite of the traditional workflow steps that developers are familiar with.At present, I am more concerned about the effect of such work.In addition, I am also very concerned about the value of this workflow.

 

Vanilla: Uh, yes.Back to the workflow, do you understand these steps?

 

Hannibai: The workflow seems to be the first step, to study the product code and find out where you want to change.

 

Vanilla: Yes, it is.

 

Hannibai: The second step is to decide on the specific design.Consider whether to add a new method or directly modify the existing code.

 

Vanilla: Then?What are the key steps?

 

Hannibai: Yes, Clarice.The third step is -

 

Vanilla: Uh, Clarice?

 

Hannibai: Let me continue, the third step is a very interesting step.We are not directly changing the code, on the contrary, we will write-

 

Vanilla: (Excitedly) Test the code!

 

Hannibai: Yes, the micro-tests written for changing code.Sometimes, we need to change an existing interface, or write a new object and function, and then use tests to drive the call to the new interface in the existing code.Determining the specifications of the micro-test is the easiest way to achieve the next function.

 

Vanilla: (Exaggeratedly) Then what?

 

Hannibal: The fourth step is to run a micro test to see if it can pass.Observe the red error message.Do you see which one (seriously), Clarice?

 

Vanilla: Aha...

 

Hannibal: In other words, it is indeed possible that the micro test will fail.But did you know, Clarice?

 

Vanilla: Ah...

 

Hannibal:

(angrily) There is no sense in writing automated tests that cannot indeed fail!

Hannibal: (Somewhat angry) If the micro-test written will pass 100%, there is no need to write it!

 

Vanilla

True

Vanilla: Exactly.

 

Hannibal: There is another reason, do you know?After we add or modify the product code, we can observe the test result from fail to pass.

The third reason, writing tests first, allows you to think from the perspective of the caller of the code.The person who calls the code is the user of the new function.It's not like eating a soufflé by yourself and quickly becoming it.Learn to write interfaces in a good way, it is impossible to eat soufflés all at once.All this is a smarter way to write code.

 

Vanilla: (I feel embarrassed and abrupt) Uh, all right.It sounds pretty good.shall we start now?

 

Hannibal: Exactly.We divide the story into two parts, one part uses TDD and the other part does not use TDD.We use a timer to measure the energy spent by each group.

 

Vanilla: Okay, why do you do this?

 

Hannibal: (clears his throat) Ah, dear Clarice, have you seen it?We must understand that TDD can indeed save time during development and testing.Otherwise, why use TDD?

 

Vanilla: Yes, it makes sense.

 

Hannibal: The time starts, let's take action!

 

(Typing sound. Music. Time passes. Ding.)

(Sound of typing. Music. Time passed. Ding.)

 

Vanilla: The test has passed.

 


Hannibal: Great, Clarice!TDD is more useful than I thought!I didn't want to see the green indicator bar, the joy of accomplishment is so good!Check out our test report!We passed 6 tests and confirmed that the code can meet our needs.It only took an hour.Check it out!Just click the run button and the test will be executed in less than a second.Each micro test only takes a few hundredths of a second.great.

 

Vanilla: Yes.

 

Jose: Take a look, what are you guys doing?

 

Junior Joe: Vanilla Pop paired programming with the top developers of Stack Overflow?

 

Jose: Pops will become another XMan?

 

Hannibal: I'm so excited, my mouth is drooling.I can eat you.

 

Vanilla: Wow, Mr. Doctor, please calm down.

 

Junoir: It's lunch time.Sir, can we...

 

Hannibal: Doctor

 

Junior: Take the distinguished doctor to lunch.

 

Vanilla: Uh, I didn't--

 

Hannibal: Great, we must have a quieter, closed place.It's best to shout out loud.I live not far from here, can I take the three of you over for lunch?

 

Jose: Of course—

 

Vanilla: Jose and I have something to do.

 

Jose: Is there?

 

Junior: We can do it for you.

 

Vanilla: No, we still need your help.

 

Junoir: Do you need it?

 

Hannibal: Oh, what a pity...

 

Junior: No, no, Pop.The doctor and I will pass, and I will help you later.

 

Vanilla: But—

 

Hannibal: Clarice, let's go.(Their voices disappeared in the hallway.) I got a croquet that I wanted very much, and I only need some fresh meat.

 

Jose: Okay, Pop.what's the situation?We have no other arrangements for lunch.

 

Vanilla: I don't believe that person.

 

Jose: You are too extreme.Anyway, let's buy a burger, I'm hungry.

 

Vanilla: I don't think we will see Junior Joe anymore.

 

(Suspense sound)

(Pause sound)

 

(Door sound)

(Door opening)

 

Vanilla: You are back, Dr. Lecter.What about Joe?

 

Hannibal: Joe said that he has something to go out.You should have lunch together, Clarice.Enjoying food is like sitting next to God, I always say that.

 

Vanilla: Ah, let me call Joe.

 

Hannibal: It's ridiculous, we still have to write code.Here, I will turn the timer off.Let's do the second part without TDD and see what happens.

 

(Typing music)

(Sound of typing)

 

Hannibal: Really exciting, isn't it?

 

Vanilla: Yes, we write code like developers usually do, then debug errors, execute the code, find and fix problems.I'm not surprised that it took so long to get the correct code.

 

Hannibal: Exactly.With TDD, we will feel as if we are doing design work, and we are a little uncomfortable.Using the conventional "found errors and then solve them" development model, we will be busy writing code, busy around the debugger, until the code can be put into use.

 

Vanilla: We even have a small program to execute our code.What a waste of time, all are manual operations.I think our tests are not deep enough.

 

Hannibal: I agree.Our test is not recorded.No record at all.It's as if we never tested it.Everyone understands, I dare say, Pop, if time is too tight, you may want to skip the test altogether.But we use the timer result to see that it saves 10% of the development time.but--

 

Vanilla: However, when there is no automated testing, our progress has fallen behind.

 

Hannibal: Exactly.

 

Vanilla: If we adjust the function, we will not—

 

Hannibal: (Sound of eating food) The delicious green progress bar tells us that everything is in good condition.It is important to know that all code is in good condition.We can release the code soon.(He stands up and prepares to leave) Mr. Vanilla Pop, this is very valuable for learning.I thank you.The investment in writing TDD's micro-test code is nothing compared to its continuous return.We can run these tests at any time.The value of a manual test run with a debugger is only one-time.For example, my dear Vanilla, what do you think if I say let us adjust the code that has not been tested, and then continue manual testing?

 

Vanilla: I am worried that I will protest.This will take at least 20 minutes to redo the work we did in the debugger.

 

Hannibal: Correct!So micro-testing produces value every day.The value of manual testing is like a flash in the pan, a one-off.Manual testing is a burden, it is true.But the psychological temptation to perform manual testing is great.However, another way, click to run, and the micro-test is done!The cost of performing all automated micro-testing is almost zero.

 

Jose: Has anyone seen Junior Joe?He doesn't answer the phone.

(Suspense)

 

Hannibal: Excuse me, I have to go now.(The sound of opening and closing doors)

 

Vanilla: Oh my god, it's like my worst nightmare.Poor Joe.I knew I shouldn't let him leave with that monster!I can't see Joe now.

 

Jose: Have you checked the code with Lecter?

 

Vanilla: Of course, why do you ask?

 

Jose: The continuous integration panel reported that a micro test failed.

(Suspense)

 

Vanilla: Impossible. We ran all the tests before submitting... Wait, see here?Someone submitted a flawed code.

 

Jose: Oh look, the built code started another test.Look at that.No matter who solved the problem, the code has passed the test.

 

Vanilla: Let me see who submitted the code.The record indicates that it was submitted by Junior Joe.He must be busy working at home.

 

Jose: He sent me a message on Slack, saying that he went home after lunch.He told me before that his cell phone signal at home is not very good.So do you still think he is a monster?

 

Vanilla: Uh, well, it's okay.


Jose: Look at the street downstairs.Isn't that Dr. Lecter and Code Dog?

 

Vanilla: Oh, my goodness, it looks like catfish has been replaced with salmon.Good luck to the salmon.

 

Narrator:

Commentary: If you like this very dramatic TDD story, then you will like to read the "Black Scrum" comic book.This comic allows you to follow Ace, a cold agile consultant, to explore and learn about Scrum together.If you don't like comics, then take a look at the novel "Black Agile Book".It tells about a project manager who transformed an existing waterfall project into agile management and brought the project to life.Both comics and novels are available for purchase on Amazon.Customers in India can buy "Black Agile Book" at Pothi.com, while customers in China can buy it at my WeChat Store (LancerKind1234).There are links to these products in the notes.

 

 

Some of the sound effects come from the followingFreeSound.orgusers:keweldogandristo_alcinovandBreviceps.


用户评论

表情0/300
喵,没有找到相关结果~
暂时没有评论,下载喜马拉雅与主播互动