It goes like this: When you notice that you’re receiving criticism, pay attention to your emotions. You’re looking for defensiveness, anger, etc. When you notice that feeling, briefly imagine a future situation in which the person who made the criticism actually implemented those changes; it can be helpful to make it slightly absurd (the example I usually use is their criticism is about my long-hair hairstyle, and I imagine they forcefully cut my hair into a different hairstyle - for your case, maybe imagine they edited your code and approved the edited version without asking you).
Now try to imagine a hypothetical future situation occurring where that change saved your ass (for my hair example I offer ‘a date goes really well, and then she offhandedly mentions how much she hates long hair on guys’ - for your case, maybe imagine your company picks up a big contract with a new client and their use case would have crashed production with your code but it holds up with the changed code). Focus on the relief you feel that the forced change ended up saving your ass. (If you have the introspection skill, try to consciously transfer that relief away from “absurd forced change” and associate it instead with merely hearing the criticism - but if that mental operation doesn’t make sense to you, don’t worry, as long as you feel that palpable relief, the technique is working.)
People have described this to me as janky and “a weird hack that shouldn’t work”, and I agree it has that feeling to it, but it’s also worked incredibly well for me and many people I’ve told it to. Over time and with practice it becomes a more fluid mental operation: eventually when you get criticism, a way in which this critique saves you some future pain will jump into your head spontaneously. Early on this will only be applicable to asynchronous situations like internet comments; as it becomes more automatic you will be able to apply it in real-time conversation too.
Try it out! The best metaphor for why it works that I’ve ever heard came from someone who took me aside a week after one such lecture and told me she’d been applying it. She said that it feels like criticism starts an “anger”-fire in her head and this technique is like imagining a firehose into existence so she can spray “relief”-water onto the blaze - essentially, that it’s a way of generating a counter-acting emotion to fight the existing emotion with.
Obviously, only use this when you want to accept the criticism gratefully. Some criticism is mean-spirited and not useful; less than you are tempted to think, but non-zero.