Exactly how to best deal with them depends on the map, primarily the settings.
What map size are you using, and what speed? Larger maps and slower speeds will cause greater barb problems to the extend that on marathon+huge your better off building the great wall at least nine times out of ten.
For standard normal settings on the other hand you can usually get away with nothing more than warriors combined with knowledge of game mechanics for preventing spawns aka spawnbusting.
Spawnbusting relies on the fact that barbs cannot spawn within 2 tiles of an existing unit. This works on the diagonals too making a 5*5 no spawn zone around any of your units regardless of fog, knowing this you can prevent barbs appearing in large areas at a low cost.