Needs More Examples. Rolling Updates.
Frequently in fiction, your typical city tends to take the view that when it comes to defense, Crazy-Prepared is good. Very good.
In fantasy or medieval settings, such a city will always have high and thick walls, which usually (and impractically) enclose the entire city. The walls will constantly be patrolled by a sizable force of guards, who are very well armed, armored, and trained. These guards will also frequently have ready access to heavy artillery for defensive use, including catapults, ballistae, and/or even (if the setting allows it) cannons.
More modern settings will feature naturally updated defenses, from electric fences to bomb shelters. Futuristic settings will have Force Fields, automated turrets, and even more strange and novel mechanisms.
Of course, the practicality and costs of creating and maintaining these defenses will never be brought up, as well as the original reasons for creating said defenses. This usually means that these defenses vaguely imply a Crapsack World; after all, there would have to be some justification for those preparations in the first place, even if it's never explicitly stated.
If these defenses are put to the test (and they usually will be), the results will vary, depending on the work. These can range from the city being destroyed to showcase how prepared/numerous/tough the armies of the villain(s) are, to pretty much holding up to whatever gets thrown at them with little effort.
This is a subtrope of Crazy-Prepared. See also The Siege. If the defenses fall, the after effects may include Watching Troy Burn.
Anime and Manga
Tokyo-3, which has a number of defensive systems surrounding the city (namely missile systems), the Evangelions, structures that hold EVA-scale weapons and buildings that can retract underground for safety. In fact, the city was built to fend off the coming Angels.
The Megacities of Judge Dredd, which have massive defenses against infiltration from the Cursed Earth, strategic and tactical air defense, and armed forces ranging from the Judges themselves to emergency Bloc militias. And entire megacities still get wiped out.
Minas Tirith from Lord of the Rings is one of the key codifying examples. Unlike some, there's a clear justification for it; after all, Sauron's forces are out there.
The Dragonlance novels enjoy deconstructing this trope. After all, defenses such as stone walls are little good against attacks from the air, like those of dragons and flying citadels...
The Forgotten Realms setting has most of the cities set up like this. Phlan is the most prominent example in the novels, falling under attack several times, but holding them off each time.
On Gor, most city-states are built like this, with walls to keep out outsiders and gates to let people in.
The CoDominium novels offer a couple of science fiction examples:
In Falkenberg's Legions, the capital city of Harmony-Garrison. Originally settled by Christian farmers, the planet Arrarat was supposed to be a peaceful venture, so the city was not walled in. Then the Bureau of Corrections got involved, and began dumping convicts on the planet. To protect its interests, the CoDominium sent a Marines who foritified the city of Harmony, and made a fortress of Garrison attached to it.
In King David's Spaceship, the city of Batav is a typical example of this, due to being on a low tech world. This is not without reason; due to local climate changes, barbarians migrated and besieged the city.
In the Legacy of the Aldenata, major U.S. cities located in territory that was deemed indefensible against the Posleen invasion were turned into fortresses that would be able to hold out on their own while surrounded by Posleen armies. New York City was one example.
The Wheel of Time has Tar Valon, which is doubly well defended due to both being surrounded by walls and being situated on an island in the middle of a river. It had fallen under siege several times.
David Eddings' Belgariad, being set in a classic 'High Fantasy' world, has no shortage of equally-classic Castle Towns. Several of them, however, goes above and beyond the call of duty when it comes to being stupidly defensive:
The Citadel of the Algars is the only permanent structure in the Algarian grasslands - the Algars are otherwise nomadic. It's practically a man-made mountain which the Algars have been constructing nonstop for centuries - they have annual drag-boulders-to-the-Citadel competitions. Its sole purpose is to be a huge target for any invading army - there's basically nothing inside except for a huge labyrinth that anyone breaching the gate can get lost in while Algarian bowmen take potshots at them from atop the walls.
The City of Riva is located on a desolate, rocky island in the middle of the western sea. It covers the ONLY sizable cove where an army could land, with a huge wall. Inside, the city is build in tiers, and every house is part of he fortification - all the walls that are turned 'outwards' are built extra-sturdy and windowless, so in case of a wall-breach, every tier can become a new wall as the defenders gradually fall back to the Rivan Castle itself - which, of course, has some pretty imposing walls and defenses. The entire reason the city was built, on a previously-uninhabited island, was to protect the the Orb of Aldur. No army has ever so much as breached the outer walls... but the defenses have, on many occasions, proved less than formidable against trickery and infiltration.
Armengar from the first Riftwar Saga, which is a highly fortified city occupied by human settlers north of The Kingdom, frequently attacked by goblins and moredhel (dark elves).
The X-Wing Series establishes that Coruscant, the galaxy's capital in Star Wars, is quite thoroughly defended, with a powerful defense fleet and a double-layered planetary deflector shield grid. A major part of Wedge's Gamble is the Rogues' effort to disable the shields long enough for the New Republic to invade.
The Sword of Shannara had Tyrsis, the capital of Callahorn. The city had a heavy wall and thick gate plus was built into a mountain. On top of that you had the Border Legion of Callahorn guarding the city. Ultimately, the defenses are not breached through strength but by treachery. Spies within Tyrsis jam the locking mechanism to the city gates, allowing easy breaching by the vast army of the Warlock Lord. Only Shea destroying the Warlock Lord stopped the obliteration of the Border Legion and the conquest of Tyrsis.
E. R. Eddison's classic The Worm Ouroboros has Carce, the heavily fortified capital of Witchland, wich is described both as a citadel and a city.
The Last Redoubt in The Night Land, which is a massive pyramid protecting humanity from unspeakable horrors that roam the darkened Earth. To ensure their safety, an electric circle that creates an invisible barrier prohibiting any monsters from entering the Redoubt.
In Magic: The Gathering, specifically the Shadowmoor block, the insanely paranoid Kithkin build all of their settlements this way.
Warhammer40000 has a Citadel Planet: The world of Cadia, which is located near the only stable passage to the Eye of Terror from which the Legions of Hell regularly emerge. Nearly three quarters of the population serve in the military, Child Soldiers are taught to use a gun before they learn to read, and is protected by its own fleet of spaceships. This being 40K, it still wasn't enough to prevent the forces of Chaos from taking over.
BIONICLE: Ta-Koro is basically a walled city inside a volcano with a sea of lava protecting it.
World of Warcraft has both Stormwind and Orgrimmar, both of which are walled up and heavily fortified. (Not that it did much good for either one when it came to stopping Deathwing...)
The Stronghold series of games easily lets you build a somewhat realistic version of this. The AI is not so good at doing the same.
In Star Wars: The Old Republic, Kaas City on Dromund Kaas. The houses the Sith Citadel, is surrounded by numerous fortified walls of its own, and has a highly militaristic "peacekeeping" force on the inside.
Savannah Citadel in Sonic Unleashed. There is a huge, thick wall around the place, but the doors in are usually open as the inhabitants are peaceful and friendly to Sonic. Just not Dr. Eggman.
The Citadel in Mass Effect is an ancient space station that serves as the galaxy's capital. In addition to an ever-present defense fleet it can close its arms when attacked and render itself inaccessible. And now the subversion: because it's so defensible, the Citadel makes perfect bait for advanced civilizations and allows the Reapers to decapitate the galaxy's leadership in one fell swoop during their 50,000 year harvesting cycle.
The Order of the Stick has Azure City, heavily fortified by an order of paladins and an army of guards. Despite the aid of the Order, the city falls to Xykon and Redcloak's hobgoblin armies.
Mechanicsburg in Girl Genius has made repelling invasions into the town sport.
Ba Sing Se from Avatar: The Last Airbender : it actually has two walls, an outer wall to protect the farmland, and an inner wall to protect the city itself.
Most medieval and ancient cities actually did have walls with a limited number of gates, and strict rules against building outside the walls. This served an economic interest: tolls on goods brought into or out of the city was a major revenue stream in medieval times. However, the city guards were more likely to be few in number and often part-timers. And siege preparation in supplies was probably only done when necessary. Most of these cities no longer have such fortifications; Caracassonne in France is one of the few still existent examples.
With the advent of improved gunpowder, new star fort fortifications, designed to limit the power of cannons and the effect of sappers, replaced the old style of walled fortification for many cities. Palmanova, a town in Italy, is regarded as one of the first examples of star fort walls being used, and the fortifications still exist there today.
Constantinople, the capital of the Eastern Roman Empire. It boasted a triple wall as well as a chain boom that protected its harbor. Many tried and failed to capture the city, even Attilla the Hun. Yet, Sultan Mehmet II succeeded with a different approach in 1453...with a powerful cannon designed to destroy said walls.
Cities deep inside the Roman and Chinese empires were often unfortified during the height of their power, it being assumed that The Empire was protecting them so well that the only reason to fortify would be as part of a plan for rebellion.
Cities along the Low Countries tended to be some of the most fortified in history as that was one of the nastiest battlegrounds in Europe. Sometimes rather then a city fortifying itself, a city grew up around a fortification that was already there.
Soviet and modern era Moscow. It's the only city in the world with a dedicated Anti-missile defense system.
Five hats means that five tropers think it is ready to publish.
You are saying that you think this draft is ready to be published. That means the description is not ambiguous,
it doesn't duplicate an existing trope, there are at least three examples, and the title makes sense.
Is that what you meant to do?
You are saying this draft has a ready-to-publish hat it does not deserve and you are taking it back.