Walls are pretty weak, having only 40 hit points, and very cheap (20 gold, 10 lumber). However, once you've started building walls, you had better go on since you won't have a multiple of 100 in gold/lumber.
Walls can be seen through the fog of war, this is a
It is well known now that farms make good walls; because you need them anyway, they are free. Farms have 400 hit points and will last about ten times longer in an attack. Barracks or a blacksmith are even better.
Something common to all wallin strategies is that they help only at the beginning. Later in the game, catapults can take the towers and walls down with a few hits. Sappers will blow away your farms in one strike. Finally, mages and death knights are the death of every wallin strategy since the can wipe out both farms and towers quickly with blizzard or death and decay.
Wallins can help you very much, though. They provide a strong defense, and the towers can easily be repaired. Their drawback is that they cost resources that otherwise could be used for attacks and that are later lost (because wallins become obsolete in the later game). The main goal is the ability to upgrade sooner because you will need less grunts to defend your town. Don't wait until you have mages because by then the towers and walls won't help any longer.
You should avoid to wall yourself in entirely. This will leave you unable to expand and helpless to catapults from outside. You should always have the option to chop out or get out by destroying one or two walls.
This is the first wallin strategy developed in Warcraft II. You build a wall around the gold mine to protect your peasants. The forest is used as an additional wall (being infinitely strong against everything except sappers). The pictures shows such a classical wallin.
To be able to expand your town, one peasant or two stay outside the wall and build. If you use farms instead of walls, you can protect your peasants with only three farms, making this wallin the cheapest.
Towers are a common addition to a wall-in. They can be put up without barracks, are relatively strong if walled in and can be repaired. These are all advantages over common units. However, the upgrades take a long time, and they become useless in the later game. Towers are also mainly defensive (unless built in an enemy town), so you should not build too many of them or you'll waste too much gold (three towers is the maximum).
This wallin developed by NaTe is now well-known. The cannon tower is protected by four farms and completely save from grunt or ogre attacks. To prevent sappers from destroying two farms at once, four walls block the crucial places. Note that the walls have not to be built before your opponent reaches the keep stage. The walls won't make a difference against two sappers, so you might leave them away. Of course you can also use this wall-in with guard towers.
What makes this wallin so strong?
This wall-in has been submitted by Plutonium. He used a barracks instead of a blacksmith and less walls, but basically it's the same. The wall-in in the picture is the fastest you can possibly get and probably the safest way to go if you want to skip the town hall stage.
These are the common wallin strategies, tell me if you know other (good) ones.
There are several ways to counter these strategies:
This is a cheap but very effective trick to prevent your opponent from getting resources on small maps. The key is not to wall in the entire mine (you're to slow for that), but build a barracks and a blacksmith between his townhall and his mine. If you build your first barracks there he won't have any grunts yet to destroy it, and you may continue with a blacksmith. Since these buildings are hard to destroy, your opponent will be slowed down a lot which means you have won. This tactics is lethal if you can wall his mine off entirely with two buildings (if it's blocked by trees then).