Asking questions is always the best way to correct someone (Hey Socrates). You avoid triggering defense, and if it turns out you were wrong, you don’t sound like a jackass.
You still have to be sensible in the way how you ask questions. Very possible to intentionally or unintentionally insult and trigger lots of other things just by "asking a question" (my speciality).
I try to channel Terry Gross. “You say it’s very important to frob the encabulator before and after you linearize the splines? Interesting, tell me more about that.” I don’t just want to correct bad code, I want to understand the misunderstandings that produced it and fix those. Otherwise you just wind up with more bad code.
"Do you know where you are wrong ?" will definitely trigger people's defense
This is why I never went into CS educationally. I was never treated in a respectful way by the Polish system. Always treated like ass