Joshua Bloch
201
used it. You have to go from the gut and talking to someone with a different
perspective can be very helpful.
I’ve known people who don’t feel this way—who are willing to program in a
vacuum. I think it hurts them. You will discover your bugs earlier—you
really want to discover problems with a design long before it hits the point
of code. So when you’re wrestling with different approaches or even
different features—should I support this and this or simply that—you just
have to bounce it off other people. On the other hand, you can’t take what
each person says as gospel because you’ll get conflicting opinions, and
ultimately, you are responsible for your own work.
Seibel: That raises another age-old question—I think Weinberg wrote
about this in The Psychology of Computer Programming in the ’70s and the
XPers talk about it today: should code be “owned” by one person who is
the only person who ever touches it or should everyone on a project
collectively own all the code so anyone can fiddle with anything?
Bloch: I believe that code ownership can’t be denied. In a way, it’s like
motherhood—you give birth to the code that you write, and especially if it’s
large, complex, or original, it is yours. If you find yourself working in
someone else’s code, talk to them before mucking with their code.
Especially if you think there’s something really wrong with it, because you
might be wrong. If you break someone else’s code, that’s not nice.
Of course, it’s bad for an organization if a piece of code belongs to exactly
one person because if that person leaves the organization, they’re high and
dry. So it’s really important that multiple people learn about each piece of
code and are able to work on it. But I think it’s unrealistic to expect
everyone to own all the code.
This also touches on what we were discussing earlier in terms of areas of
expertise. There aren’t that many people who can really write bit-twiddling
code, so if you find yourself in the bowels of some code that’s doing bit
twiddling, you should talk to one of the few people at your company who
can actually handle that stuff, if you’re not one of them. People who do this
stuff love it and are willing to spend whole days reducing an instruction
sequence by one instruction or proving some identity that speeds up a
computation. But it’s so easy to break something. And it’s so easy to write