4 ms·
It doesn't look like a good approach to me. There are a lot of bad code out there and the only thing you can learn from it is how to write bad code. The import
by Nekorosu 10y ago
It doesn't look like a good approach to me. There are a lot of bad code out there and the only thing you can learn from it is how to write bad code.
The important things are the right mindset, the ability to reason about code quality, and good set of more concrete skills: algorithms and data-structures, beginner level understanding of different programming paradigms and their applications (class-based OOP, prototype based OOP, FP, you'll get a deeper understanding of one or several of these approaches when you start using some specific language), particular language features, idioms and libraries which can help you solve real problems.
Most of these things can't be deducted from reading code. Some of them can but again you have to read good code. The suggestion to just read a code of the thing you use is bad. You have to find a mentor who can direct you to the idiomatic and effective code.
The best thing you can do after getting used to the right way is to solve some problems and then improve your own code until it shines. Then you can read a code of the libraries you use and maybe improve it.
- scarecrowbob 10y ago"There are a lot of bad code out there and the only thing you can learn from it is how to write bad code." Oh, I dunno. I've done it a bit and found value in it. I spend big chunks of time writing customizations or extensions for WordPress plugins. It's not exactly a fun way to make a buck but it is easy to be better than most folks writing for WP and I work remote from a tourist town... but my point is that I have read a shit ton of really bad code. If you think that all it's done has made me able to write bad code, fair enough... I'm not exactly solving difficult problems. But I still feel that it's good advice to read other peoples' code. The benefits of knowing that you can do better than some folks aside, being frustrated by some poorly documented code that is difficult to reason about is a really great way to understand why you shouldn't write stuff like that, and the various ways in which things can get messy. It's not the best thing in the world, and I suppose that on some level its struggling against rather than reading this code which is the real benefit. But I agree with Stephen King when he writes in _on Writing_ that there is value to writers in reading some bad novels. If you've been working for a while and want an easy way to improve your practice, and your general impulse when working with other folks code isn't to follow down to that code from your IDE, there is a lot of worse advice than to just go ahead and look at underlying code other folks have written.
- Nekorosu 10y agoI get your point. One of my points is reading somebody else's code isn't for beginners. This looks aligned with your last sentence.