TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Coding backwards

140 点作者 jobeirne超过 13 年前

16 条评论

gte910h超过 13 年前
This is just top down development.<p>Works great in many cases instead of bottom up development. It really is a design methodology:<p><a href="http://en.wikipedia.org/wiki/Top-down_and_bottom-up_design" rel="nofollow">http://en.wikipedia.org/wiki/Top-down_and_bottom-up_design</a><p>You just happened to be designing as you were going along coding
评论 #2910459 未加载
shaggyfrog超过 13 年前
Amazon takes this to the extreme and writes the press release for the product first.<p><a href="http://www.quora.com/What-is-Amazons-approach-to-product-development-and-product-management" rel="nofollow">http://www.quora.com/What-is-Amazons-approach-to-product-dev...</a>
评论 #2911922 未加载
nickolai超过 13 年前
Top Down approach works great for smaller or exploratory projects, yet i have had a few unpleasant cases of "cornering myself" - cases where a significant rewrite was pretty much required because a crucial implementation constraint was not visible from the top.<p>With small or ill defined projects, throwing out bits here and there is expected - but i suspect the method can pose serious issues to larger ones.<p>Example : Quote of Feynman's report on the space shuttle<p><a href="http://science.ksc.nasa.gov/shuttle/missions/51-l/docs/rogers-commission/Appendix-F.txt" rel="nofollow">http://science.ksc.nasa.gov/shuttle/missions/51-l/docs/roger...</a><p><pre><code> The Space Shuttle Main Engine [design] was handled in a different manner, top down, we might say. The engine was designed and put together all at once with relatively little detailed preliminary study of the material and components. Then when troubles are found in the bearings, turbine blades, coolant pipes, etc., it is more expensive and difficult to discover the causes and make changes. For example, cracks have been found in the turbine blades of the high pressure oxygen turbopump. Are they caused by flaws in the material, the effect of the oxygen atmosphere on the properties of the material, the thermal stresses of startup or shutdown, the vibration and stresses of steady running, or mainly at some resonance at certain speeds, etc.? How long can we run from crack initiation to crack failure, and how does this depend on power level? Using the completed engine as a test bed to resolve such questions is extremely expensive. One does not wish to lose an entire engine in order to find out where and how failure occurs. Yet, an accurate knowledge of this information is essential to acquire a confidence in the engine reliability in use. Without detailed understanding, confidence can not be attained. A further disadvantage of the top-down method is that, if an understanding of a fault is obtained, a simple fix, such as a new shape for the turbine housing, may be impossible to implement without a redesign of the entire engine.</code></pre>
评论 #2912608 未加载
Breefield超过 13 年前
I found this a while back, (<a href="https://zetabee.com/cashflow/demo" rel="nofollow">https://zetabee.com/cashflow/demo</a>) Quite useful, exactly what he's proposing too.<p><a href="http://news.ycombinator.com/item?id=2333570" rel="nofollow">http://news.ycombinator.com/item?id=2333570</a>
评论 #2910469 未加载
viraptor超过 13 年前
Why does this appear again and again? Why isn't it on every single programming related course:<p><pre><code> amount = 14., </code></pre> Is just asking for trouble...
评论 #2911217 未加载
jerf超过 13 年前
I sometimes like to write the documentation for the module, to varying degrees of completeness, before I write any code. I find that for infrastructure modules it really helps to make sure that you're writing an API that serves the API user, instead of serving the API designer, because you discover right away if you're writing an idiotic API.<p>If you want to smear a thin patina of faddishness over it, you could declare the documentation is a form of TDD, except that we're testing something that automated testing simply can't, which is the effective usability of the API from a human point of view. But then, I'm not too worried about yon thin patina of faddishness. Sometimes it's the right tool for the job, often it isn't.
评论 #2910871 未加载
kaylarose超过 13 年前
This is how I approach project design as well (after the POC phase): Top down (API first). Then (not covered in parent article) bottom-up, (a.k.a. what building blocks does that API need?). _Everything else is just glue._<p>If you exclusively do one or the other, you end up in bad territory. Top-Down: Results in excessively bloated API logic. Bottom-Up: You end up with a muddy API, that is overly complicated &#38; hard to use (it's more of a RPC lib than an API).
评论 #2911010 未加载
ww520超过 13 年前
Good work in coming up a unknown design approach by yourself.<p>This is basically test driven development, or before that the object orient analysis. That guy interviewing you was following the object orient analysis approach. OO is sort of out of favor with all the functional fads in force.<p>OO Analysis is actually quite elegant, despite all the complication added later on. It can simply go by this:<p>1. Describe in English what your system will do. Be specific about the actors involved and their actions. e.g. Let a user projects earnings and expenses over a period of time; summarize net effect.<p>2. Pick out all the interesting nouns and all the verbs. The nouns become your classes and the verbs become the methods.<p>3. Pick out the interactions between the nouns. Added those as methods on the receiving classes. Figure out the data of the interaction, which becomes the method parameters.<p>From that you can do the TDD approach to build the tests to exercise the skeleton code according to your system description. And from that fill out the actual functionality of each method as you run each unit test.
评论 #2916372 未加载
5hoom超过 13 年前
I'm but a lowly humble indie developer unschooled in techniques such as test driven development, yet I often find myself doing something like what the author describes.<p>The bit that rings true for me is that he decided to "write out a script using the yet unwritten API".<p>I have found my designs to be much more succinct &#38; workable when instead of writing a bunch of classes then figuring out how to get them all to play together, write the code where the proverbial tyres hit the road &#38; then go back to fill in the details.<p>I'm sure the more experienced software engineers out there would facePalm at this method &#38; it's obviousness, but it gets the job done ;)
stdbrouw超过 13 年前
We're really coming full circle here, eh? Next thing you now people will start advocating the waterfall method again.<p>More seriously though, it all depends on what you're writing. Sometimes TDD works best, README-driven development (<a href="http://tom.preston-werner.com/2010/08/23/readme-driven-development.html" rel="nofollow">http://tom.preston-werner.com/2010/08/23/readme-driven-devel...</a>) is really nice for certain projects, sometimes top-down is a good thing and sometimes just hacking away without having a clue about what you're doing turns out surprisingly well.<p>There's way too much discussion about methodologies and way too little about when they shine.
pseudonym超过 13 年前
It's an interesting thought, but doing this for anything on any real scale is going to bite you in the ass when it comes to use cases.<p>Unless you program every single view/controller out with no model, which means you're throwing together reams of code with no way to test it.<p>Interesting as a first step if you're stuck, though, but I don't see a lot of worth in this over pseudocoding the app as a design step, either.
wccrawford超过 13 年前
Congratulations. You've discovered TDD without the tests.
评论 #2910450 未加载
评论 #2911057 未加载
评论 #2910566 未加载
toadstone超过 13 年前
I'm more curious about what the alternative is because this is my default mode of programming. I don't see what's backwards about it. You establish what you need in the module first, then code. What else can you do?
评论 #2910929 未加载
petercooper超过 13 年前
This is quite a common approach in the Ruby world, where issues of API design and readability frequently trump other concerns (with both good and bad outcomes).
njharman超过 13 年前
&#62; I’d reverse-engineer a good design by pretending I’d already written one!<p>Um, I call that tdd.
cincinnatus超过 13 年前
Always write the user docs first.