Minecraft wiki entry for Iron_golem_farming, associated text: First fence in the village and light it up, and add a few beds to encourage the villagers to breed while building the farm, which will take a while. Remove any high blocks near the outside of the fence, to prevent hostile mobs from entering the fenced-in area. Once the village is fenced in, you don't have to worry about villagers interfering with your work, which happens outside the fence in the crook of the "L". Proper lighting also prevents any hostile mobs from spawning in the village.