I once had to advise someone who found himself irritated at receiving lots of comments during code review. I think my response was good enough to quote verbatim:
This problem arises because you are too attached to your code. Your ego is associated with the code you write and you feel that any comments or defects found reflect upon you as a person.
You are not perfect. You will not write perfect software, and that’s fine. It’s not a flaw, it’s just the way software is. It isn’t written all in one go, magically perfect and elegant and satisfying all the requirements. Good software goes through multiple iterations and many eyes looking at it.
It is also important to treat it as a learning experience – learn what you can from each code review comment and try to apply what you learn to future code you write. This also helps you minimize review comments in the future. Instead of treating the large number of comments as a shortcoming on your part, treat it as a metric you can improve upon.
It’s probably true of any endeavor which results in creation – be it programming, arts, crafts or whatnot – that you need to be able to divorce yourself from your work so that you can accept and analyze and learn from criticisms objectively and without feeling terrible about yourself.
Fun fact: All programmers write terrible code. Yes, even the veterans, the rock stars, the elite, they have all written terrible code at some point in their careers and they will probably write more terrible code in the future. The key is to recognize those instances – either through introspection or being open to criticism – and learning from them and trying to minimize them in the future. Or at least correct them earlier!