In academic philosophy (and I'm sure elsewhere as well) recommendations have gone through several decades of grade inflation. So many letter writers have exaggerated the merits of their students for so long that, no matter how enthusiastic a letter is, if all it has got to convey is enthusiasm, its readers will dismiss it. An effective letter is, in practice, an argument for the assessment that is its conclusion.
This means, first, that in order to have someone write you an effective letter, you have to supply him with the materials for that argument. If you're a student, having taken more than one class with a would-be recommender helps. So does speaking up regularly in class, and turning up during office hours. And so does writing to higher standards than the grading scale in your class; grade inflation means that you can get good letter grades without giving your teachers the wherewithal to write a strong recommendation. Don't just rely on your recommender's memory: keep your graded and commented assignments (e.g., papers) on file, and be ready to give him copies when you ask for a letter; if he's reading a sizable piece of your writing (such as a dissertation), let him know you'll be needing a letter, so he can compile notes on it while it's fresh.
(My own policy: I take my job to be to write the best letter that I can, given what's in those materials, along with my records from classes you have taken with me; however, if I'm not formally your supervisor, and I've already taken on too many letters, I may just not have the time, in which case, I'll beg off. I will compose what's basically a little essay around what I have in the pile, and again, it will be the best that I can write. Sometimes students want to know, ahead of time, how strong their letter will be, but usually that's not a question I could answer, even if I thought it was a good idea to do so. I won't know what the letter can come out being until I've worked my way through the inputs I have available for it.)
Second, don't wait till the last minute to ask for a recommendation, especially the first time through. Writing an effective letter of recommendation usually involves reading through a stack of writing -- the farther along you are in the field, the larger the stack. An effective letter has to have a high level of polish, and so it normally requires more than one draft. Faculty have other commitments, and you have to give a letter writer a reasonable amount of lead time -- six weeks is a good minimum. (However, once someone has written you a letter, they will normally keep a copy on file; unless there's been a big change in your situation, or what you need the letter for, subsequent letters will be much less work, and can have shorter turnaround times.)
Recommenders appreciate it when you're organized. Even if you ask in person, you should write him a letter that lays out the information he will need in an easy-to-follow format, including: What the letter is for, when it is due, and what address it should be sent to. In order to comply with our university's interpretation of FERPA (this is the law the protects the privacy of students' education records), it's not enough for you to ask me for a recommendation for me to be able to talk about your grades; I will need a signed form for my files, explicitly stating that you grant me permission to disclose both your grades in classes you have taken from me, and your grades on assignments in those classes -- fill this in under "Other". (Sorry, this is CYA required by our bureaucrats; I know, it's a waste of everyone's time, but we have to do it.) Even if the grade release form is inappropriate -- i.e., if you're not a present or former student -- I will need a signed waiver (even if you do not want to waive your right to see the letter -- in that case, check the "don't waive" box); this goes for dossier/job placement letters as well. If I am going to be the recommender, and you are applying for an academic-year graduate fellowship, your letter should include a statement to the effect that if you receive the fellowship you will not take on any teaching commitments during the fellowship year. And you should be prepared to provide an appropriate reading stack: if the letter is going to be written on the basis of course work, the graded papers you wrote in the class; if you're applying to graduate programs or if you're on the academic job market, a copy of your writing sample; copies of publications, if any; if you're finishing up graduate school, a copy of your dissertation or dissertation draft.