It depends on how well I know you, and whether I feel I can write a good letter for you. Part of the latter is that I need to feel that I know you pretty well as a person, not just as a student in a course. So: chances are, if you were in one of my classes with 200 other students, then I don't know you very well unless you made a point of coming reguarly to talk to me after lecture or during office hours. Also, you need to have done well in my course if you're going to ask for a recommendation (at least a mark of A- or above).
You can ask me whether I am willing to write you a letter in person or by e-mail. I always have my office hours posted on my webpage, so it should be easy to know when you can find me. If you are asking via e-mail, do the following:
If you ask me to write a letter by e-mail, then it is highly likely that I will still ask you to come see me in person. In particular, I may or may not agree to write you a letter based solely on your e-mail.
IMPORTANT (note about deadlines): You absolutely MUST ask me at least ONE MONTH in advance of your deadline(s) if you want me to write a letter. I will NOT honor last-minute requests or any requests with less notice than one month.
If I ask you to come see me in person, it is because I feel that I need more background information. It may also be that some time has passed since you were in my course, so I want to meet with you to get reacquainted, and to ask you about what you have done since you have been in my course.
It is also possible that I will ask for some time to look over your supporting materials (see next question below) and think it over before giving you a final answer.
You should make sure that I have the following supporting material. You can either send these in electronic format to me via e-mail beforehand, or (preferred) bring me hard copies when we meet in person.
If and when I agree to write the letter, I will give you my best estimate of when I expect to have it done. You are welcome to send me a brief email to ask me or remind me to do so. It is always my intention to send you e-mail to inform you that they are done, as soon as I have put the letters in the mail and/or sent off the letters electronically. It is always possible that I will forget to do this; hence you are welcome to contact me if the date has passed and you have not heard from me.