Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Copy and paste doesn't help you at all with this.

Generally I agree with this, but there is a way to use copy-pasta as a learning tool. If I find a code sample that does what I want but don't understand it, here is what I do:

1. Add a comment with a link to the source for reference.

2. Rename the variables.

3. Comment the parts that I understand.

4. Flag the parts I don't understand with a simple // ? comment.

5. Research the parts of #4 until I understand them, and then update each comment accordingly.

#2 is incredibly important to me. I've been doing some walk-through tutorials lately (e.g., http://learn.knockoutjs.com), and if I use the same variable names as the tutorials suggest, then I'm just transcribing. The code doesn't stick in my head, and I'm not really learning as much. But once I start changing the variable names, then it sticks.

#3 might seem like a waste of time, but I've found with conceptually difficult code, having the #3 comments helps keep me grounded if my brain gets too muddled.



There should be one more step:

6. Make changes to it so that it does the same thing, but in a better way -- faster, smaller/more concise, etc.

I think that being able to do this (correctly) is to truly understand, since then you are "thinking beyond the code" and can see the problem that it solves, not just an implementation that solves it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: