1. Small team of programmers, sharing a closed office.
2. Small team of programmers sharing an open office.
3. Team of programmers each with their own office.
4. Team of programmers in one big room.
5. Team of programmers in one big room along with a bunch of other people.
Small team, in a circle, with their backs to each other, was by far the most productive environment I've ever experienced. We could concentrate on our work, but when shit happened we could turn to look at our compatriots screen and help each other out.
You have to be a real team for this to work. Not just a bunch of people with the same employer.