Ditch (fortification). In military engineering, a ditch is an obstacle designed to slow down or break up an attacking force, while a trench is intended to provide cover to the defenders. In military fortifications the side of a ditch farthest from the enemy and closest to the next line of defence is known as the scarp while the side of a ditch closest to the enemy is known as the counterscarp.

Uses 
In early fortifications, ditches were often used in combination with ramparts to slow down the enemy whilst defensive fire could be brought to bear from the relative protection afforded by the rampart and possibly the palisade.
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. However, moats may also be dry.

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.

Elements of a ditch in an artillery fortification (16th to 19th centuries)

 Scarp: the inner side of the ditch (closest to the fort) is called the scarp (or escarp) slope. This may be revetted with masonry or brickwork, in which case, it is called the "scarp wall".
 Cordon: a course of protruding masonry along the top of a scarp wall, intended to make it harder for an enemy to stand a ladder against it.
 Rampart: the actual wall of the fort which can be made of earth or masonry, is topped by a parapet for the defenders to fire over, and usually slopes away from the ditch (the "exterior slope").
 Berm: a ledge between the scarp wall and the exterior slope of the rampart, designed to increase the stability of the rampart and prevent any falling debris from compromising the ditch.
 Faussebraye: a secondary parapet between the rampart and the inner edge of the ditch.
 Carnot wall: a loopholed wall between the rampart and the inner edge of the ditch.
 Chemin de ronde: a pathway running along the berm, behind the faussebraye or Carnot wall.
 Cunette: a narrow channel that runs along the floor of the ditch for drainage purposes.
 Bartardeau: a type of masonry dam across a ditch that is part wet and part dry.
 Counterscarp: the outer slope or wall of the ditch (furthest from the fort).
 Sally port: a small door allowing the defenders to enter the ditch should it be occupied by the enemy.
 Caponier: a masonry or brick structure extending into the ditch or traversing across it; it is pierced with loopholes to enable the defenders to fire along the floor of the ditch.
 Counterscarp gallery: a passage constructed behind the counterscarp wall and pierced with loopholes, which enables the defenders to fire on attackers who have entered the ditch.
 Glacis: an earth slope angled away from the ditch; the height and angle of the glacis was calculated to protect the rampart from direct fire but to allow the defenders to fire over it.
 Covered way: a path running between the outer edge of the ditch and the glacis, allowing defending troops to move around the exterior of the fort; it was usually provided with a banquette or fire step so that defenders could shoot over the crest of the glacis.
 Place-of-arms: an open area of the covered way at an angle of the ditch, where defenders could assemble for a sally or counter attack.

See also
Border barrier

References

Fortification (obstacles)
Earth structures