Carpet moat

A carpet moat is a simple, reasonably attractive mob barrier that players can pass over at any point.

Structure
A carpet moat consists of a row of signs with carpet placed on top. That's it! Mobs that approach from the low side will not "see" the carpet and therefore don't jump up a step. They just keep bumping into the edge of the carpet without figuring out what the barrier is.

The moat has to have a one-step rise in altitude. If you need a ditch before the carpet, make sure it's at least two blocks wide or spiders can span it.

The moat can be one-sided - a pen to keep domestic mobs in, or a barrier to keep hostile mobs out. Or it can be two-sided, as shown in the cross-section, to do both.

Carpet can also be used to moat a flat space, with signs-on-signs spanning the gap. The ditch must be at least 4 blocks wide and 6 blocks deep. Mobs will see the ditch but not the carpet, and will not cross it unless pushed, led, or thrown by an attack or explosion. There is a moat in the street in Pickaxe Mesa that keeps the area in front of the blacksmith's shop mob-free (the original villager area).

Construction/Repair
To place carpet on a sign, or to place a second sign on an existing sign (to span an opening or go around a corner), crouch/sneak while placing it.

Limitations
Creepers can easily blow large holes in the moat, so don't stand close to the border if you're not paying attention.

It's easy to break the carpet while fighting a zombie or especially spider that's up against/under it.

Baby mobs who grow up while standing under the carpet will grow "through" it, and may then step up out of it.

Golems and knockback weapons may toss hostiles up and over the moat.