Ask YC: Could you point to examples of great and terrible code
I have been a bit isolated and self-taught for my CS education (online at University of Maryland). One of the holes in my education is that I feel like I've missed out by not working with and looking at other people's code. I could use some examples of what people consider to be great code and what's terrible code.
I'd love to see what other people think is great code and/or terrible code. If you have access to code that you think is great or terrible and is freely available online, I'd love to see it.
24 comments
[ 3.1 ms ] story [ 61.0 ms ] threadThe bigger the project the better because more people have looked at it and offered suggestions.
Look for great code, terrible code is everywhere.
Why do I cite Mono? It's not becuase I am a Microsoft nut, but because Mono is a re-implementation of MS code. Mono people had a great reference for design, which allowed them to focus only on writing good code. What I have seen of Mono's implementation is really good code.
Bad: Sendmail - it works but is continually plagued with bugs ~ http://www.outpost9.com/exploits/sendmail.html
Here's an article on him, by the way. http://www.topcoder.com/tc?module=Static&d1=features&...
I switched my blog over to typo because I just couldn't stand working with the writhing mass of spaghetti that is Wordpress (once you get under the hood, anyway).
1) Only short code snippets. It does not take much to write a brilliant 10 lines of code. Give me at least code for a well-designed class.
2) No comments. Of the top snippets, I only saw one that had comments.
So it's kinda useless to go to that site. The idea's really good though, lots of unrealized potential.
1) The code in the book "Paradigms of Artificial Intelligence Programming" by Peter Norvig. (on the surface this is a "good lsp style book" but in my opinion you can learn a lot about writing good code in any language from this book)
2) I second David Hanson's "C interfaces and implementations", reccomended by Maro in his reply.
3)The code for the HotDraw framework (smalltalk and java)
It's very instructive to read the source of the parser and the code generator for the VM. It's well commented and it just flows.