Many of the issues that affect the quality of the reference you will get depend on how you govern yourself over the course of your studies, and by the time you ask for the reference, your reputation with that professor may not be, shall we say, ideal for the purpose of getting a “good” reference. Some students seem to be oblivious as they diminish, bit by bit, the reputation they will need later when it is time to ask the professor for a reference. Presuming you do not have a time machine to make repairs when your job search and grad school applications come around, being conscious of your actions as a student will help you later.
I have good marks. Isn't that a "good impression"?
By cultivating a good impression, I don’t mean that a professor will give a better reference to a student who is unctuous or fawning. I mean, do not be a student who reads the word “unctuous” in the course notes and asks the professor what it means. A student who looks the word up in the dictionary or already knows the word will get a better reference.
In a word, what creates a good impression?  Be reliable  Make sure your questions are good ones  Be about learning