I've never been a developer, but I've been a tester, and this is the way we used to estimate how long a testing job would take. Basically, we would estimate how long it would take us to do the job if everyone left us the hell alone and we were able to concentrate entirely on that job. Then, we'd quadruple it because, inevitably, something would come up and we'd have to deal with some other random thing on some completely different application.

Of course, that's for apps we're already somewhat familiar with. If we have to also get familiar with the app, we'd factor in some "read the docs and play with the app to see how it REALLY works" time as well. That'd add oh, about 25% to the base estimate (before quadrupling).

We generally got things done within our stated timeframes. Those few times we finished way ahead of schedule made us look like miracle workers.;) But, really, it all comes down to the psychology of dealing with management/customers. You want to underpromise and overdeliver.