There is also a difference between
- time needed to complete a task (which you should learn to estimate when you acquire experience)
- and delay : time to complete that task, plus time to do other things that are more urgent
About the estimation of time needed to do something :
- the first time you do something, it's hard to have any idea of how long it will take to complete it
- but, as time goes by, you will have done more and more different stuff ; and, each time, you'll remember how long it took you.
After a while, when asked "how long will it take you do do that ?", you'll be able to think :
- "that" is quite similar to the other thing i did on project X, and that other other thing I did on project Y
- I spent 8 days doing it on project X, and 6 days doing it on project Y ; but it was much easier on Y, because I already had some idea of how to do it (already done it on X)
- so, on this new project, it shouldn't take more time than on project Y
- actually, I'm even better now, more experienced... So it should take about 5 days
- and to not put too much pressure on yourself, and keep some margin of error, you say 6 days, or 6 days and a half to your boss.
- and, in his head, he will add another day ^^ (or, if he his the kind of guy who count 4 when he hears 6, just tell him 8, and he'll understand 6 ^^ )
As time passes, you'll get better and better at this ; and, in the end, you'll probably become able to :
- estimate how long it should take you to do something you never did before
- estimate how long it should take for another developper to do it
- and this, both for an experienced developper,
- or for a beginner
- or just for one specific guy
Ho, and I forgot : I generally add about 15% of the "development time" for tests and corrections of bugs, btw -- it's a standard rate, for projects I worked on, and generally quite accurate (of course, for a beginner, who will probably create more bugs, you'll add a bit more ; for an experienced developper, a bit less).
Yes, of course, sometimes, you'll be totally wrong ; it happens, that's it : everyone makes mistakes once in a while :-)
About delay : well, I generally tell my boss "it should take me X days if I don't have to do something else" ; then, if my boss tells me to do something else for 2 days in the middle of my task, it's "his fault" ^^
When working alone on a project, or being "my own boss", I generally know how much time I have to spend on "other stuff".
ON a project I worked some time ago, I used to tell the client : "I need 5 days to do this, but considering I generally spend half of my time doing not planned stuff, let's consider it'll take me 10 days total" -- after a while, you get used to count like this ^^