Skip to content

Comment on Reading Other People's Code

Comments

how much time do people spend reading other people's code?

am i unusual (lucky?) in having to do very little of this? usually i am developing new projects or maintaining things i wrote. even when extending existing work, reading the existing code is only a small part (largely at the start).

Even working mostly alone, I read other people's code frequently. We all depend on libraries and platforms written by others and none of them are perfect. There are always bugs, performance problems, or missing features down there.

You get the simplest code in the least effort if you solve each problem at the appropriate layer. People who never look down into the layers below them end up with lots of unnecessary duplication and cruft.

> You get the simplest code in the least effort if you solve each problem at the appropriate layer. People who never look down into the layers below them end up with lots of unnecessary duplication and cruft.

Well said. True in general, but especially when you're working on some middle layer of a large scale project, it really pays off to understand what's going on at least on the adjacent layers.

This does really sound unusual. For me, the ratio of reading to writing is about 4:1. Are you sure you are not writing too much new code, because you didn't invest the time to properly understand the existing one?

When you mostly work with your own code, do you still have that feeling of constantly improving your coding style and code quality (like looking at code that is X months old and knowing you would write it differently today)?

that's probably a good point, in that i have been trying to get the people i work with to think more abut code re-use. i sometimes worry we have too much of a culture of "make our own version" (but see below).

but also, i think it's just the nature of the work we do - typically i am asked to implement something new for a third party (i'm more a hired gun or "consultant" than part of a development team).

so probably it was a dumb comment of mine to post without reflecting more first. sorry.

ps to answer your last question - when i work on my own projects i do a lot of rework. at work i rarely get the chance, because one contract finishes and another starts. but not sure what you were getting at there.

Thanks for the clarification. This sounds valid.

In my last question I was just wondering how or when you (or others) tend to improve their coding style. For me its mostly when reading other peoples code and noting that a) certain aspects are great or b) not so great. But maybe that just comes naturally to me because I don't have that much experience under my belt.

"Lucky" is in the eye of the beholder. Where I work, code review is a regular event, so there's always another set of eyes on your work to help you catch issues that aren't the purview of unit tests. It's also a great way to learn from more experienced developers.

which got me thinking. is there any place where you can get code reviews? something like a book club, but each week you review someone else's code. could be online or local meetups...

This is rather late, but http://codereview.stackexchange.com/ was made for this purpose. Post code for improvements, or review other people's code to suggest improvements. Working code only.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.