A ditch in scarp while the side of a ditch closest to the enemy is known as the counterscarp.
In medieval fortification, a ditch was often constructed in front of a defensive wall to hinder mining and escalade activities from an attacker. When filled with water, such a defensive ditch is called a moat.
Later star forts designed by military engineers like Vauban, comprised elaborate networks of ditches and parapets, carefully calculated so that the soil for the raised earthworks was provided, as nearly as possible, entirely by the excavations whilst also maximising defensive firepower.
Today ditches are obsolescent as an anti-personnel obstacle, but are still often used as anti-vehicle obstacles (see also berm).
A fence concealed in a ditch is called a ha-ha.