The walls and the 
yagura towers surrounding the Japanese castles were, of course, built for defense, but they were also designed to create an interior space for the  main keep (
tenshukaku). Considering how the 
yagura were connected with the 
tenshu, there are several styles of construction: directly (the 
Fukugoshiki style) or via a more or less complex passage (the 
Renketsushiki style).
But the simplest version is the 
Dokuritsushiki style, where the main keep isn't connected to any 
yagura, as you can see in this wide angle photo of Maruoka-jō, the castle with the oldest 
tenshukaku from Japan. 
EXIF info:
Nikon D90
Lens: 8-16mm F/4.5-5.6G
Focal Length: 8mm
Aperture: F/5.6
Shutter Speed: 1/320s
ISO Sensitivity: ISO 640