Hacker News new | ask | show | jobs
by johnfn 3336 days ago
I see this advice often. However I feel like it never seems to work for me. One of the big reasons why is that I feel I don't get a sense of all the incorrect approaches and why they don't work.

In a case where there are N incorrect approaches and 1 correct approach, by reading the code of the 1 correct approach I will get no sense of why the author dismissed the other N approaches. I feel this (understanding trade offs and judging which approach is best) is a crucial aspect of programming that is easy to miss when reviewing the solution that worked.

1 comments

I get what you're saying and that's one of the reasons the code should be deeply analyzed when you're learning, many times you'll find the answer to why that particular approach was selected. Very often authors point out why other approaches aren't suitable for that speciic purpose, many times theorically or by using abstract concepts.
Analysis here can also mean rewriting it yourself from scratch (perhaps in high-level pseudo-code) the next day. If you can't make the same decisions the author did or understand them, then analyze again.