Town and Fortification in the Early Modern. A complex relationship

Which is the relationship between town and fortification? In a traditional perspective this has largely been considered a question of defense of the civilian population. However, this factor, though certainly important in several cases, cannot be seen as the only relevant factor addressing the problem. There are also other traditional explanations. One of these relates to questions of paying custom for selling and buying items. The fortified enclosure would make control of payment easier.