My university programming courses taught me to write code, but my internship has shown me that I'm still terrible at reading it. I'd like a book in the style of chess tactics trainers, full of what's-wrong-with-this snippets, preferably in C or C++.
Exceptional C++ and its sequels are just what you're looking for. They contain programming puzzles of the "what's wrong with this code?" type. posted by pravit at 6:21 PM on June 10, 2008
Code Complete is a great text for some of the real nuts and bolts of coding.
As for getting better at reading code, let me paraphrase something I had heard second hand from a comics convention. A fan boy asked a prominent artist how he too could become a prominent artist. The answer was to get a really big stack of paper and a lot of pencils and start drawing.
Same thing.
Whenever I start working with other people's code for the first time, I usually step through the whole flow with the debugger. I've gotten to the point where I can pretty much tell you what OS the coder has spent most of his/her time on strictly by the style of the code (as opposed to the OS calls). Recognize nuance in the coding. Some people write code to be read. Some people write code to be fast. Some people write code to be terse. Some people write code to be clever. Ask yourself what the code is whenever you read it. Spot the design patterns. Spot the redundant work better spent in library routine. Spot the useful abstractions. Spot the gratuitous ones. Be critical. posted by plinth at 6:54 PM on June 10, 2008 [2 favorites]
I haven't seen the 2nd edition but when it first came out, Code Complete was the best design/coding book around. So this is a seconding of plinth's recommendation. posted by storybored at 8:13 PM on June 10, 2008
Also, I've been a long time out of the industry, but there must be some open source projects that have a reputation for coding excellence...someone else who's up on the latest might be able to help here... posted by storybored at 8:16 PM on June 10, 2008
Code Complete is a great text for some of the real nuts and bolts of coding.
Absolutely positively. I actually finished reading the 2nd edition yesterday morning and damn, it's great. The only thing I didn't like was that I took this long to read it. posted by Nelsormensch at 8:19 PM on June 10, 2008
When faced with a piece of code that I really need to understand, I sometimes start by rewriting it line-by-line in the way I would have done it. posted by grouse at 3:08 AM on June 11, 2008 [1 favorite]
posted by pravit at 6:21 PM on June 10, 2008