When we're doing things that hurt people because we want to change their behavior (which I think morally we shouldn't do in the first place, but setting that briefly aside), it is absurd that we don't even ask "does it work?"
I was in a classroom yesterday and kept hearing from the other kids that when a kid did some action that adults had determined they shouldn't, this or that punishment was enacted. I then asked, "does it work? Do they stop doing the thing or do it less?" And the answer was no.
No.
Still setting aside the morality of punishment as behavior modification, it wasn't an effective tactic for this individual.
IT DOESN'T WORK
Even if it looks like it works in the moment (because you've shocked or scared the kid), it doesn't work to actually teach the lesson of why they need to avoid that behavior, and without that underlying foundation, at best all you're going to get is them understanding that they need to hide the behavior from you. Which is not what you want.