top | item 20843079

(no title)

squirrelicus | 6 years ago

14 years in the industry, and I often describe typing the code as the easy part of software engineering. Once I'm typing the code, I already know in large part what code needs to be typed. The hard part was understanding the problem model enough to know what code to type.

That being said, executing the code while typing it is critical. You cannot build a mental model of all edge cases. At best, your personal discipline will allow you have habits around preventing and catching edge cases. But you won't find enough edge cases just by thinking about the code to type. You do have to discover them by running the code, and the sooner you discover them, the faster you will be at producing high quality code.

As far as how much time I spend building a mental model vs coding... It's at least half mental model time. If I happen to predict enough edge cases, then it might be 90% of the time. But the critical part is that I'm not done until I've exhausted the edge cases I can imagine. If I discover sufficiently big edge cases that brick my code, it's time to step away from the computer and fix my broken mental model.

Note: tests are a way to do this, but so is white box poking and prodding at your program in debug mode.

discuss

order

mstade|6 years ago

Are you me? I started coding professionally in 2004 or 2005 (if memory serves) and a few years of tinkering before then. Your process describes mine almost to a T – building the mental model is the hard part, writing it down is mechanics more than anything else. It used to be the other way around; I didn't know how the mechanics worked so I worried more about that than the ideas, they seemed the trivial bit but over time that shifted. Not quite sure when it tipped over, but it definitely did.

(The last nota bene of your comment is particularly striking to me. I love tests and I try to automate them as much as possible, but sometimes you just gotta prod and poke the thing to really get a feel for it.)

einpoklum|6 years ago

For me - it's sometimes like that, but sometimes it's the exact opposite: I understand the problem through starting to code. Depends on the coding task; also on the language.

squirrelicus|6 years ago

I'm sure everyone is different, but it's worth saying that I find myself spending more time in the writing code phase with dynamically typed languages than statically typed languages.