There is also a difference between teaching and grandstanding; the reality of the situation is that there is no single correct response for this kind of situations: the junior maybe was zealous, maybe he was trying to shame the senior, maybe he just copied in CC the wrong mailing list.
Obviously the original answer was not appropriate in every situation, but also likely it was appropriate in some.
Obviously the original answer was not appropriate in every situation, but also likely it was appropriate in some.