For above ground threats:
I use a series of walkways and archer tower to defend against anything that can't shoot back. For the ones that can I make them walk through a twisting passageway with ballistas at the end of each hallway and a series of dwarf atom smashers, cage traps, animal bait and weapons traps after all that. If they get through all of that(highly unlikely) I still have my drowning chamber within my fortress and a pitfall trap connected to levers inside my barracks. If they somehow survive the pitfall I put in stonefall traps and another ballista at the exit as well.
For underground threats:
I have 4 bridges with one on top of the other in which any enemy will have to walk through and I can pull it out from under their feet to make them fall 5-9 stories down till they hit the ground. For the flying enemies I make a room after the bridges with a magma and water trap and since there is a ceiling on top it'll make them come down to the ground where I can pull the various lever and trap it in a room and fill it with magma and then water from the top in-casing them in solid obsidian.
Of course I also set up detection animals all alone the entrances and exit to watch for ambushes way before they get anywhere close.
Needless to say all I really worry about is internal threat to my fortress like tantrum spirals and such.
Of course for everything else that doesn't go to my fortress I also have 2 archer squad(1 legendary) and 2 melee squad(1 legendary) to chase and kill anything that could get through everything.