Who
- answers the subject of the question
- the answer of the question should be the object form of pronoun
- E.g. Who wrote the codes? He wrote!
Whom
- answers the object of the question
- the answer of the question should be the subject form of pronoun
- E.g. By whom was the window broken? By him!