It looks a bit more like gated communities than historical construction, but there's the *fantasy* for you. Frankly, if you have magic (or the right kind of labor pool and resources), so that the cost of building the walls isn't too high, and you can actually man them adequately (which requires less man-power if you are defending against small raiding parties or stupid monsters than if you need to hold off an army that will launch coordinated attacks at multiple points), then you can afford to spread out a little more. Advantages are being able to keep some livestock inside the defenses (thus protecting them as well), avoiding crowding that helps spread disease and assists pickpockets, and space between buildings to slow the spread of fires (so the whole place is unlikely to burn down in one big fire, a serious risk historically).