"How did I do this" or "how did I do that"?

Is there a difference between:

How did I do this?

and

How did I do that?

If not, is there a preferred one? If they are different, when should I choose one over the other?

I am not a native English speaker.


If the task you are wondering about is right in front of your eyes or you chose to do it yourself, use "this". If someone else brings that tasks to you and you're wondering how to tackle it, use "that".

If I remember correctly, "this" usually refers to something closer to the speaker than "that".