Is the top or bottom design?

In my memory, most people tell me that I should design from top to bottom. If I want to implement a web page, I should draw or draw this page on paper, Then divide it into some functions. For each function, I try to design external APIs and implement their internals separately.

But in TDD, they said I should consider a very small function (One way?), first write the test, fail, implement it and pass the test. Writing them is the last step. I can’t imagine how it gets a good API.

The strangest thing is that they say TDD Not only unit testing, but also functional testing. I think it means top-down. If there is a function A composed of methods B, C, and D. Because of TDD, I first write a functional test for A. But… B, Both C and D are unimplemented. Should I use three stubs? What if B depends on the other three methods?

I wrote some small programs with TDD. But when I used GUI to attack the application, I got into trouble.

I have been writing a lot of rspec tests for my rails project, maintaining a ratio of about 1:1.6 between code/test. I have never really solved what to write first or what to rely on. Question. If the method A I want to write consists of B and C, then I will first use the correct test to implement B and C. For me, as long as the test is good and accurate, the sequence is not that important.

So, I did not use stubs as you described, but only when the feature already exists and I just want to bypass/bypass it.

By the way In one sentence, it is considered a top-down approach. This is an excerpt from Rspec Book:

If you ask experienced software delivery folks why they run a project like that, front-loading it with all the planning and analysis, then getting into the detailed design and programming, and only really integrating and testing it at the end, they will gaze into the distance, looking older than their years, and patiently explain that this is to mitigate against the exponential cost of change—the principle that introducing a change or discovering a defect becomes exponentially more expensive the later you discover it. The top-down approach seems the only sensible way to hedge against the possibility of discove ring a defect late in the day.

In my memory, most people told me that I should design from top to bottom. If I To implement a web page, I should draw or draw this page on paper, and then divide it into some functions. For each function, I try to design external APIs and implement their internals separately.

But in TDD, they said I should consider a very small feature (a method? ), first write the test, fail, implement it and pass the test. Writing them is the last step. I can’t imagine how it can get a good API.

The strangest thing is that they say that TDD is not only a unit test, There are also functional tests. I think it means top-down. If there is a function A composed of methods B, C and D. Because of TDD, I write a functional test for A first. But… B, C, D are all Unimplemented. Should I use three stubs? What if B depends on the other three methods?

I wrote some small programs with TDD. But when I used the GUI to attack the application, I got stuck.

I always In writing a large number of rspec tests for my rails project, maintaining a ratio of about 1:1.6 between code/test. I have never really solved the problem of what to write first or what to rely on. If I want to write method A by B and C composition, then I will first use the correct test to achieve B and C. For me, as long as the test is good and accurate, the sequence is not so important.

So, I did not use stubs as you described, but only when the feature already exists and I just want to bypass/bypass it.

By the way, it is considered a top-down This is an excerpt from Rspec Book:

If you ask experienced software delivery folks why they run a project like that, front-loading it with all the planning and analysis, then getting into the detailed design and programming, and only really integrating and testing it at the end, they will gaze into the distance, looking older than their years, and patiently explain that this is to mitigate against the exponential cost of change —The principle that introducing a change or discovering a defect becomes exponentially more expensive the later you discover it. The top-down approach seems the only sensible way to hedge against the possibility of discovering a defect late in the day.

< /blockquote>

Leave a Comment

Your email address will not be published.