I taught Princess to sit then 'wait' before I open the door. That's still with her leash on that I'm holding but I just wanted her to understand she can't go out until I say ok or come. We don't have a fence here, I use a long leash to give her a little more freedom.
As for the electric fences, no way I would use them on any dog. What happens if they get away from you as you leave the vet or pet store...they run & feel nothing, hmm, must be ok to go until they do.

It teaches them nothing, IMO. I don't believe they learn to stay in the yard, they're just learning to avoid that painful shock. There are some pretty interesting videos on youtube of full grown humans trying these devices & it doesn't look pleasant. Can't imagine it on the body of something a fraction of an adults size.