The purpose of walls varies. If you're trying to protect your agriculture from marauders (human and otherwise), you'll want to put walls around your fields if you can afford it. If you want to protect your people, walls will be around the storehouses, dwelling places, and water source. If you expect fairly prompt relief from a siege, you can have smaller walled areas. Frequent or lengthy sieges would probably tend toward more area enclosed (again, if you can afford it). Type of wall will also vary, as massive and high stone walls are intended to guard against people and inspire awe; natural things like deer or predators can usually be fended off with something like simple palisades. Earthworks are always important, because it's a cheap way to get both a defensive ditch and higher ground with the same effort.

I'm not trying to be annoying about your thread, BenjaminGPointer, but you keep showing thing that happen to hit on my fairly limited interest and knowledge range.