Doesn't really help. Your settlers run outside the gates like idiots when you're attacked. Turrets in strategic locations are more helpful.
However, walls look really cool when you get them right.
I guess, I just walled off the sides off the bridge, added a prefab to the mix to the only bridge into town, added some turrets too. I did build more walls this morning to just simply grind up more XP. With the rest of the settlements I'm not sure, I just try to add them where it feels like they would be needed. Just a judgement call I think it really boils to so ... up to you how you want to handle that until someone tells you otherwise.
You can if you want to. You can keep it open, or wall off a smaller section of it, or whatever you like.