Earlier quoted context omitted.
Depends on who you want to protect against. For example if you want to protect against hordes of teenagers stealing everything from an Apple store, you just need a button to deploy barbed wire at all entrances and exits, and then a few guards with rubber batons beat the shit out of everyone. When the state is weak, communities take the law into their own hands, which is why we see this medieval-style fortifications a…
Actually, the best way that doesn't get you bogged down in battery charges (for beating a teenager) or manslaughter charges (oops, your barbed wire caused a fatal infection) is social services that help fight poverty and teenage vagrancy (and possibly an accessible iPhone model that takes the edge off of the iPhone jones/envy that your iPhone marketers purposely built).
You don’t get battery charges when there isn’t a functioning state with courts, police and prisons.
City fortifications are an indication that the functional unit of society has compressed to city scale.
It can collapse further to single buildings — castles and further to nomadic warring tribes.