The Dragon #10 (October, 1977) contains an article entitled "Let There Be A Method To Your Madness" by Richard Gilbert, outlining the merits of a rational approach to dungeon design. It was reprinted in Best of Dragon #1 (1980).
A room in the dungeon, as appearing many years ago (above) and to explorers today (below). Illustration by David C. Sutherland III
Before you do anything with a dungeon, you should have specified where it will be located, what the surface area looks like, and what, in capsule form, its history is. The two chief items of the history are its age and who built it. Age is important, especially time elapsed since it was last in regular use, because it determines the condition of any perishable items found within, and for some worlds, what sort of artifacts could be present. The builder, that is, the being who caused the castle dungeon to be built, is the single most important factor to develop before actually working on the dungeons.
*This approach was used by Mike Carr in module B1 "In Search of the Unknown" and Jean Wells in the original version of module B3 "Palace of the Silver Princess", both "second generation" dungeons.
About a thousand years ago, a local tribe erected crude stone fortifications here for their women and children. The site was in use for a few centuries and then abandoned. About four hundred years ago, a young, energetic wizard named Nappo claimed the site. He brought in a few hundred orcs and built the present castle on the old foundations, expanding outward and downward. The orcs were put to work creating a dungeon complex, which project continued off and on until Nappo’s death...
The builder, Nappo, was a wizard, so at least one level is needed for labs, libraries, and storage of related equipment...
The upper levels should have living space for several hundred orcs, with attendant storage, kitchens, perhaps temple space, and maybe even sewers or some system for waste removal...
Here also would be the main armory, with its own guardroom or other security precautions, plus fairly easy access to drinking water.
Below these levels would lie cells, torture chambers, and anything else intended mainly for the orcs use, such as possibly an arena for practice and entertainment.
Leading off in a separate series of levels would be Nappo’s part of the dungeons. First, a number of levels devoted to guardrooms, mazes, and traps to snare intruders. Then would come Nappo’s underground quarters, from which one would gain access to labs, animal or monster pens, and Nappo’s treasury.
Add guest rooms with corridors, plus secret passages for the builder to spy on them.
Was the builder a temporal ruler? Add throne room, conference rooms, guard rooms, more secret passages, and perhaps a regalia room...
A gourmet requires extensive kitchens and pantries, along with a host of attendant small rooms.
In European history, ruling men created comfortable nests for their lovers, which were as lavish as the men pleased or could afford.
As a final thought, if you want a really well-fleshed dungeon, throw in the religious element.