IMHO, a worse practice is when you are happily typing along and the system throws up a dialog randomly, grabbing the focus and thereby "pressing" one of the buttons when you thought you were typing. Who knows what you just agreed to.
I'm glad that KDE has options to prevent that: https://docs.kde.org/trunk5/en/kwin/kcontrol/windowbehaviour...
Generally if you were interacting with the computer then whatever new thing should get focus iff its appearance was a direct result of your current interaction.
Truly its crazy making.