The firing pin of a centerfire gun is designed to strike a primer located in the center of a cartridge's base. When no cartridge is present, the firing pin strikes nothing.
While this is correct, a bit of further explanation is in order. The firing pin actually does strike something, your gun. When there is no primer to be struck, the pin goes a bit further, until it is stopped by "striking" some part of the gun. USUALLY its a shoulder on the firing pin, striking the rear of the boltface. But different gun designs different. The point here is that with no cartridge or snap cap in place, the firing pin stops when metal hits metal.
SOMETIMES this can be a problem, over time. Again, it depends on the gun, its design, and the materials involved. Some guns are made to take thousands on thousands of "snaps" (without caps) and suffer no ill effects.
Other guns, especially old guns, (and notably old shotguns) are not as "durable" in this aspect, and a lot of snapping can lead to crystallization in the metal, and firing pins breaking, even though they "hit nothing".
If possible, check with the maker, and see what they say. I have a Ruger Blackhawk manual that specifically says "Dry firing will not harm this gun".
I also have a 109 year old shotgun that if I ever caught any one "snapping" I'd feed them a different, less sentimentally valuable gun, butt first!!
Having NOTHING in the primer pocket is the same as having nothing in the chamber, far as the firing pin is concerned. Something with a degree of elasticity is best. Glue, hard rubber, plastic, lots of options, but having something there for the firing pin to strike is the best thing.
Dummy rounds can be used as snap caps, but be aware the reverse is not always true.