News for hackers. Stuff that matters.
Re:Functions Should Be Short And Sweet, But Why? by lstamour on Wednesday January 22, 2014 @03:22AM (#7101456)
This reminds me strongly of some concepts I've heard of in TDD Ruby circles though I'm certain they're not unique to that. The bit on writing your function names first is like the practice of "write the test with the API you want to use, then make it pass with an implementation that does just that." It's a kind of planning-by-wishful-thinking that just seems to work in certain scenarios. But I think for it to be successful, you need to read enough best-practices code in your target language to understand better approaches. That said, using your phantom code first will give you a better API design. The trick, as in this article, is to keep writing ideal implementations like turtles all the way down. If your logic is complicated enough that you'll need notes or comments, descriptive function names are wonderful. Particularly in languages like Objective-C with named parameters.
Re:Functions Should Be Short And Sweet, But Why? by cheapsteak on Wednesday January 22, 2014 @03:37AM (#7101511)
I've thought about it as the programming equivalent of writing outlines before starting on an essay. It requires more forethought, but you can recognize early on if a line of thought / solution is a dead end, and also makes restructuring and fixing it much easier
Re:Functions Should Be Short And Sweet, But Why? by henrik_w on Wednesday January 22, 2014 @04:05AM (#7101601)
I often end up factoring out things into common methods in the end. That's when I see what parts are common, something I don't always recognize in the beginning (or even in the middle of it).