I like to be sure about defense, so I've evolved a particular Entry Hall setup. This takes some time to get going initially, especially with some bugs I've noticed where rock that's fallen down a Zlevel seems to never get picked up for hauling. I should note that fallen rock can be used for a construction, so I sometimes build silly stuff that will get destroyed just to get the dwarves to move rocks out of the entry path (so Carvans can get inside unobstructed). Sometimes I also simply issue a Stay Inside order and use a lever to retract the bridges to drop any stray rock the hell out of the way.
4wide ramp down to the first sub level. ~5 rows left as ground for traps and pressure plates. Channel out 18 rows (still 4 wide), leave 2 rows as ground, another 18 channeled, 2 more ground rows, and a final 18 channeled out, with five more ground rows at the end. Everything above all of this is channeled out to make them outside tiles, so the Stay Inside order keeps dwarves out of this area (which is where the falling rock bug causes lots of problems, since rocks seem to block caravans).
Each 18 channel section gets two 10row retracting bridges, so total there will be six bridges (each 4 wide and 10 long) covering the 3 sets of 18long open spaces. The first row before the bridges start is pressure plates linked to each bridge, set for any creature that's not a dwarf. The rows between the ramps and the plates are weapon traps (10 obsidian swords usually).
The rows next to each bridge section (the 18s) are also channeled to create open space; but the ground sections between bridge pairs are left unchanneled to support that ground. I then create a long 3-5 wide room along each side of the Entry Hall, smooth the bridge facing walls, and carve fortifications. These are the barracks, usually with ammo storage, beds, and archery targets setup.
Below the bridge pairs, channel down as far as you feel you want/need to (usually at least five Zlevels). These are the pits, and the bottoms can be further trapped if desired. I like simple stonefall traps down there, since caravans will never be transiting this area, and thus can't be obstructed by any stones.
Let's see if I can put in a simple web-o-gram:
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+00000000000000000++0000000000000++000000000000+0000
^ttttp=------------------==------------------==------------------=tttt.
^ttttp=------------------==------------------==------------------=tttt.
^ttttp=------------------==------------------==------------------=tttt.
^ttttp=------------------==------------------==------------------=tttt.
+00000000000000000++0000000000000++0000000000000+000
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
^ ramps
t traps
p pressure plates
= bridge with solid ground beneath it, anchoring it
- bridge over the pit
0 open space
+ solid rock
F fortification carved wall
Whole thing is fairly idiot proof once you've given the Stay Inside order and activated your military. Dwarves will mill about in the fortress proper, away from the bridges. Any invaders that enter the hall are sliced up by the initial weapon traps. Any that make it past those step on the pressure plates before hitting the bridges. They're usually just past the halfway point (just onto the second bridge of the first bridge pair) before the bridges retract and drop them into the pits.
I use three bridge sets because it not only seems very dwarfy to over build the hell out of anything, but also I'm not sure if there are any FAST mobs that might be able to clear 40+ squares before the pressure plates react. I link each pressure plate to each bridge because when I was evolving this setup, I initially had plates in front of each bridge, and on the first serious siege, I watched in horror as they made it past each bridge before the plate finally triggered the retract. Now any plate retracts ALL the bridges, so far guaranteeing a pitting of any hostiles.
Meanwhile, marksdwarves are lighting them up from the barracks rooms while they're hitting weapon traps and falling from retracting bridges. The channeled open space that runs alongside each bridge ensures the invaders can't get up next to the fortifications, and thus can't return fire very well. I suppose you could leave this as ground (instead of open) if you wanted it to be funny, for more weapon traps, so invaders are further sliced and diced as they attempt to get next to the fortifications.
I place the stairs leading down into the pits inside the barracks, so anyone who somehow survives the pitting, and pit traps, and climbs back up the stairs, is in the barracks where your military can have a further crack at'em. Honestly, if anything survives the fall into the pits, you need more traps down there, or it should be deeper though. The point of this is to kill'em.
I also suppose, though I've never done it, for extra dwarfy fun, you could fill the pit with magma. That seems a waste though; any invaders that fall into the magma have their gear lost to you. I rarely make crafts or any trade goods past the first year since ambushes and sieges bring more than enough value to let me shower caravans with high cash amounts. This is good, since I've noticed giving the caravans massive amounts of export value causes them to crank up how many wagons they arrive with, and thus they bring more stuff to buy.
Very helpful, since I've not yet found a map that has both magma and enough trees to run a serious steel industry, build enough beds, and keep the brewers and stockpiles stocked with barrels and bins. I usually start getting 100-150 trees via import around year three.