Do programmers perform better when working from office or from a location of their choice? Also do they work better with fixed timings compared to flexible hours?
This depends highly on the individual programmers involved, and the need for collaboration, teamwork and mentoring.
I've seen teams fail because the programmers all worked different hours in different places, and couldn't keep on the same page or share knowledge quickly by ways such as instant whiteboard meetings in the hallway, talking over cubicle walls, pair programming, etc.
I've also seen teams perform poorly because programmers who who liked to code all night were expected to come in for too many morning meetings after a long commute, and ended up too sleep deprived to get in the groove and meet schedule.
If you have management flexibility, I suggest varying the routine near the beginning of a project, and find an unbiased observer to estimate if any type of routine seems to help or hinder the team on average. If the programmers are employees in a competitive market for their skill sets, you also have to include job satisfaction in any decisions.
Programmers work better when they are happy. If working from home or having flexible hours is important to some developer then allowing him/her to do that will make them happier and will probably increase their productivity or performance. If those thing don't matter to the developer then it will have no effect.
All of those essentially boil down to personal preference.
I much prefer flexible hours but going to the office. Some of my coworkers prefer fixed hours but working from home. A few go to the office for fixed hours as well. Another guy works from home very strange hours, and usually only for meetings are his whereabouts known. We are all very good performers, because we have the flexibility to work for what works best for us individually.
As I said, I prefer working at the office, but that doesn't apply to everyone.
There's a theory on motivation out there that if you focus on the performance of meaningful work (like writing high quality code, and being accessible to coworkers to help with problems and agree on design decisions) instead of on fairly meaningless details - like where the work is done (home/office), when the work is done (flextime) or how long it takes to do the work (timecards), that the people who do this type of work will be both more motivated and more productive.
That said - the focus on the value and nature of the actual work may dictate scenarios that necessitate core hours, colocation, or other rules. It depends on the corporate culture, the circumstances of the individual programmer, and the nature of the project. For every case where added flexibility is a performance enhancer, I could probably come up with a counter example where in certain specific cases, it that same point of flex would have a negative impact overall.
The good news is - there doesn't have to be a one right answer.
I definitely work better from home and the reason is the simple fact that creative insights seem to occur to me at the most unlikeliest times: in the shower, in a dream!!, listening to music etc. This almost never happens to me in the office!! Also I prefer to work half-naked which obviously wouldn't go over well at the office. I final reason is that I can smoke which in my case definitely increases my productivity!!
It also depends on the commute. For example, I like going to the office because at home I have too many distractions. But if traffic makes my commute home a 1 hour+ ordeal every day, then just the thought of getting back home makes me angry. Also the fact that I only live 5 miles from work but still can't go by bicycle (crazy city traffic) really frustrates me. I tried walking a couple of times but there are some really shady neighborhoods that are very dangerous. This is why I like my really flexible hours :)
I prefer at home with flexible hours because I don't think sitting at a computer for 8 hours straight (with lunch thrown in there for a short break) is healthy. I like to get up and move around every so often and do something non-work related which you can't really do in an office. Also, sometimes I want to stretch out, lay on the floor or something for a little while since my back tightens up sometimes and you can't do this at an office. Overall I just feel more relaxed and focused at home.
The answer here, for me, is directly related to programmer motivation, and depends both on the people you're working with, and on the type of work that you are doing.
Is your software development team intrinsically motivated? Do they have significant reason to perform well in isolation? Do they find themselves happier, more self-actuated, when given the freedom to choose where and when to work? Are they experienced/talented enough to be able to perform without assistance and supervision from those around them? Is the work easily divided into chunks that can be worked on independently of time and location? If you've answered yes to most/all of these questions, they you're looking at a team/person/project that will likely benefit from flexible hours, and flexible location. Your team will get together when and where is appropriate, and produce better and more quality work.
If, however, your team is extrinsically motivated (say, they are highly paid hourly contractors working on a boring project), are not invested in the project/company, are inexperienced or not particularly talented, are working on work which depends on heavy, regular, interaction with other team members or clients - then you're looking at a team/person/project that will most likely produce better work when mostly working out of an office, with pre-argeed on fixed hours.
All of this, though, comes with a caution: decisions on how to reward, compensate, and motivate your employees are more of an art than a science. Programmers are not unusual in this sense, and there is a large enough variety of work places and conditions to make generalizations difficult. There are general guidelines you can follow, but you've got to be on the ball and know when and how to adjust them, and for who. Maybe your team all works during core hours in the office, but you arrange for them to work part time from home for the first year of their newborn's life, because for that temporary period it's the best call for your team.
Working from home is painful, working in an overcrowded office is a horror (excepting unlikely cases when an openspace is full of extremely disciplined and considerate people).
My productivity grows when I can start my work at midnight and continue until I want to stop. (Yes, meetings, phone-calls, and another pleaures prevent me from doing it this way. What about this?)