The construction of defensive structures such as city walls and fortified castles dates back to ancient times. City walls were designed primarily to repel an attack launched by ground-based forces, and they performed adequately in such a situation. However, coastal cities were also vulnerable to attack from sea bombardments, since even a city wall left sea ports relatively unprotected. The best way to protect the port was to keep the enemy out of range of the city. This was accomplished by constructing fortresses to cover the approach to the city. These coastal fortresses, built at the mouth of the city's harbor or on barrier islands, would hold enemy vessels at bay, turning away or thinning out the attacking force and minimizing damage to the city's port.