4 ms·
As a terrible programmer my trick is to read statements backwards. Maybe programming should be taught that way too not just reading of it but the history of it
by dghughes 8y ago
As a terrible programmer my trick is to read statements backwards. Maybe programming should be taught that way too not just reading of it but the history of it all the way back to Charles Babbage, Ada Lovelace and even weaving looms.
- Waterluvian 8y agoI do code reviews backwards. Not sure why. I'm not sure it works better.
- noname120 8y agoThis makes sense. Reading code forwards overwhelms your working memory because lots of information is at the beginning (e.g. class members). If you read it backwards, you directly dive into the logic, while variable names give away what they're supposed to hold. As you progress further, you get a clearer view, and finally see how these variables are defined.
- tlb 8y agoBetter to organize code backwards in the first place. Within a file, I try to start with the juicy logic and then work down to the boring support functions. C++ makes this slightly inconvenient because everything has to be declared above its use, but JS lets you organize things with very few constraints.
- asaph 8y agoI write my code backwards so if you review it that way you'll actually be doing the code review forwards. :)
- lordnacho 8y agoThat's what I was taught back in undergrad. I can't quite remember the context, but I do remember having to start at the end and tracing backwards when looking at some simple programs.
- dgellow 8y agoCurious about this. How do you do that? Shouldn’t you still have to read the statement forward to then be able to read it backward? I can see in lispy languages how you could do that, because of the structure of S-Expressions, not sure how you would do that with more conventional syntaxes (let’s say C-like). I think that personally I do a lot of back-and-forth in-between forward and backward reading to construct the program logic in my working memory. Edit: maybe, could you describe what you mean by reading backward? I read it originally as “reading from the first expression to be evaluated to the last one”, but I see now that you are talking about statements. If that’s the case I see a lot of issues related to the context/scope of a statement. Do you read, let’s say, from the last statement before closing a function, then up?
- dghughes 8y agoAs I say I am a terrible programmer the best example I could think of was this for Python 3. float_num = float(input("Enter float num: ")) The way I read it is: I need to enter a number, the number is input, it's a float, that number will be assigned to the variable float_num. It's not the best example but for me at certain times it's far clearer. Most times it seems like I am reading the equivalent of a person writing backwards then it dawned on me to read it backwards.
- dgellow 8y agoYep, that makes sense said like that :)
- tpurves 8y agoAs a product manager, I have often found it beneficial to write requirements backwards. Start first with the desired result of a feature or flow and work backwards to the necessary steps, options, preconditions, actors, setup/enrollment steps etc. that would have been required required to get there.
- icebraining 8y agoTDD is essentially the same.
- breakall 8y agoPersonally I have to be careful of this....it’s easy for me to focus so much on the solution that the problem is never even clearly articulated to the developers (who may have a better solution that I came up with once they grasp the problem). I ran across an interesting essay on Medium recently on this topic, advocating a new approach to roadmaps focused on the problems: the problem roadmap. Instead of saying what new features the team will be working on in the future, map out what problems they’ll be working on.