If you want to understand the key to programmer productivity (and any other task that involves the manipulation of a large number of inter-dependent ideas) read Joel On Software.
What it comes down to is this - interruptions are really, really, really bad for productivity when you are doing this type of work (because every time you are interrupted you need to reassemble all the ideas you were holding in your head in exactly the relative positions they were at the point you were interrupted). The lack of interruptions is one of the main reasons I like working from home (the other reasons are being close to my espresso machine, my wife and the ski lifts, but not necessarily in that order).
However when I'm visiting one of my company's offices I usually end up working at a cube in what we call a 'business centre'. The idea is widespread in big consulting companies now and is usually referred to as 'hot desking'. It's driven by bean counters who believe that it saves money which on the face of it is true because you can squeeze a lot more people in the same amount of space. Of course it's only a saving if you completely ignore productivity, which in my experience is about 25% of what it is when you have a quiet private space (like my home office), at least if you measure productivity in terms of producing the stuff that we deliver to clients and actually get paid for as opposed to 'busy work'.
But someone in our office in Wellington, NZ has taken the concept to new levels of stupidity because the 'business centre' is also the coffee break room. Try preparing a presentation to a client to close a multi-million deal while a dozen people are taking their lunch break around you. I really wonder how the guy that came up with this can justify taking a salary.