by penteract · 2y ago · 0 comments
This may be good advice for yourself in the past, and for many people at lots of times, but I'd hesitate to give it as general advice. Reading code others have written should not be understated as way to learn valuable things from fundamental patterns and algorithms to language features and idioms. If you have a job in a team, this may happen anyway, but it's possible to write lots of code without realizing there's a better way.
I completely agree with the claim "There is no substitute for doing", and I might even say that code you read without running and tweaking it doesn't count.
To learn how to implement computer programs, read books about it.
Also, "To learn how to implement computer programs, read books about it." contradicts the original comment's "There is no substitute for doing" more than I'm happy with.
I read about them and tried to apply them.
That's backward and didn't produce anything good.
I started to understand them by doing it the other way around:
- Coding, solving problems.
- Reading other people's sources.
- Then reinventing half a terrible design pattern.
- Later on, looking at a book: "ohhh, that's what I tried to do" or "ohhh, hence the snippet in that source".
- Now I can discuss with people about the pattern and name my code entities according to that.
Design patterns are a communication tool.