Yes, and no.
It doesn't make sense to copy the fortifications of medieval castles exactly and expect them to have the same cost benefits in a world filled with magic and which single warriors are capable of fighting off small armies. So, if you are only going to make copies of medieval castles, then that doesn't make a lot of sense.
That said, the advantages of firing from behind an arrow slit remain pretty high. So, at some level, castles remain extremely valuable peices of military technology. There just have to be some adjustments made to take into account the challenges presented by PC's. I say PC's because its PC's that seem to most frequently be assaulting the strong hold of some despot who's family has been ruling the area for generations and overcoming all thier defenses with relative ease. It stands to reason that castle defenses which could effectively withstand the assault of the PC party could effectively withstand just about anything, so design around that.
1) Features related to resisting air attack: Hoardings will need to be a permanent feature of castles. All interior courtyards need to be defensible from within. Important resources (say wells or armories) need to be positioned such that a commando team mounting an air assault will not be able to cut off access to them. Vertical spaces now require protection via overlapping fields of fire. Hoardings require arrow slits in the roof areas and positions for firing through same. Castles need to be designed such that towers can protect the vertical space of adjoining towers. Points in the castle layout which cannot be overlooked need to be minimized. The castle needs to be secured from intrusion at every point, and not just along the lower levels. Bars need to be on upper floor windows. Accessways and hatches need to be strongly made and secured from the interior at all times. Ramparts need to be covered with hoardings (this can't be emphasised too much).
2) Features relating to resisting stealthy attacks: Chiefly, this means invisibility or similar means. Major access ways need to be guarded with creatures with the scent ability and with some special training for detecting to and responding to invisible beings. Think of them as the D&D equivalent of drug/bomb dogs at airports. Dogs are good and cheap, but major powers may wish to invest in keeping more powerful or intelligent trainable beasts, or else employ allies that can otherwise detect invisible creatures. Sensitive areas can be protected by curtains (often with bells attached to the bottom) or doors with guards. Major powers should have permanent or semi-permanent magical wards designed to set off alarms whenever an invisible creature passes through thier area. If they don't already exist, variations on the Alarm spell and Magic Mouth spell which allow this should be high priorities of all magical researchers in your campaign world.
Traps don't really work well for high traffic areas, but there can always be some blind corridors, false leads, false doors and such in little traveled areas of the castle. A few traps do alot to discourage explorers from sensitive areas. Several magical traps are low enough level that they can be fairly regular features of even low magic campagins, for example explosive runes and fire trap. New guards can always be warned that the third floor corridor of the west wing is to be avoid unless they want to die a horrible death. Clever castle owners could simply spread rumors of this sort. Backed up by one or two real traps, this will greatly complicate the planning of anyone preparing a commando assault.
3) Features relating to resisting scrying attacks: Important areas need to be lined with thin lead plates so that secret meetings can occur. In the major halls of power, magical wards (or even traps) designed to prevent scrying should be made permanent if they are available.
4) Feature related to resisting large monsters: Monsters with high DR or extremely high AC (or both) represent major threats to even large groups low level fighters. Balista's, mangonels, and other aimed (non-ballistic) heavy weaponry therefore are much more important to fantasy worlds than they ever where in the real one. Castles in the fantasy world need to be built at least in part more like the gun decks of later period ships. This provides the castle limited protection from armies (due to the low firing rate) but can give even a reasonably large dragon serious pause if protected by suitable hoardings. Likewise, fire is a very effective weapon against most regularly encountered high DR monsters, and burning pitch/oil/alchemical fire is much more important to protecting a fantasy castle than fire ever was to real warfare of the period. Just think about anything you've ever seen in a Ridley Scott historical revision and assume that its reasonable for your fantasy game. Small stores of silver tipped arrows and anything else which can be manufactured reasonably cheaply for overcoming DR are essential elements of any well stocked armory.
5) Features related to resisting evocation attacks: Area of effect evocation attacks are the bane of low HD creatures. The improved evasion provided by an arrow slit is important, but its equally important that the structure protecting the defenders of the castle not be easy to destroy. Again, hoardings are essential. Standing on open ramparts and firing through the battlements when the sky is open over your head just doesn't cut it in a world with fireballs and flying mages. Compartmentalizing interiors provides limited protection. The best protection is to keep the magic on the outside of the castle. It should be assumed that defenders are smart enough that anyone that waves a wand around will immediately become the target of every defender in the castle that spots him. It's probably prohibitively expensive to magically protect a whole fortress, but major powers will likely be able to afford magically prepared fighting positions within the castle. This can include tower rooms with a perimeter protected by permanent magic circles against opposing alignment (if you allow that sort of thing), magically hardened walls, or features with built in energy resistance or SR. Most castles should include a chapel area, which can be hallowed in the case of the defenses of major powers. Dispel magic is a particularly effective attachment to a hallowed area.
6) NPC's will take advantage of whatever monster abilities are available in your campaign: Important NPC's are not sitting around waiting to be killed by random monsters. While the average peasant can't afford defenses against PC's or things in the monster manual, that's why they pay thier taxes. Defending on the alignment of the powers that be, various sorts of animals/monsters can be trained or hired as castle defenders. Some suggestions include Bugbears, Worgs, Giant Eagles, Gargoyles, Griffins, Hill Giants, Hippogriffs, Ogres, Owlbears, Pegasi, Spider Eaters, Dogs, Elephants, Mastadons, etc. Small numbers of these would be unable to overrun the castles defenders by themselves, but would provide an elite force that could reasonably square off agaisnt a powerful attacker. The basic rule is this - if there is even the most remote chance that the PC's are capable of assembling a small force of such creatures - then the NPC's have already done it.
7) NPC's will form parties too: Every castle can reasonably be assumed to contain the elements of a spontaneous adventuring party as a rapid reaction force which is of a level appropriate to the stature of the castle and the power level of your campaign. This group should be well protected against stealthy and surprise attack, and should assemble to stop any spearhead lead by other above average level characters. This isn't to say that I'm advocating a FR style campaign where every third person is 9th level or higher, but it is to say that a responce team of 2nd-6th level NPC's is probably reasonable for almost any campaign. Add additional levels if you think average people in your campaign world are above 1st level. PC's also set the standard in terms of NPC knowledge. Anything that your PC's are willing to insist that they should know should be general knowledge to anyone of a similar educational background. If this is the case, you are not metagaming when NPC's respond exactly like PC's would when confronted with problems like invisible creatures and the presence of various seemingly obscure monsters.
8) If high level magic is common, high level magical defenses will have been developed: If people capable of casting teleport are fairly common in your campaign, then spells which prevent teleport will be commonly used to defend critical areas. Magical societies will put alot of priority on developing defenses against the misuse of magic. If magical items are common in your campaign, then wealthy NPC's will horde them against emergencies.