I have noticed that pigs can dive underwater, so most chicken farm models fail. They climb ladders and can jump, so it looks like there's no easy way to build a farm that I can get in and out of easily, and still have my pigs. What am I missing?
I use pits.
Dig a pit at least 2 deep and preferably not higher than 3 deep so you won't take damage jumping in, then, place a single ladder along the side on the bottom row (middle if you made it 3 deep). With a combination of W and jumping, you should be able to get out easily, while leaving your animals trapped.
It's very easy to get them in, too. Just lead them up with some carrots and stand next to the edge. They should follow you to the edge, and you can easily push them in.
I find that animals will on loading glitch through fence if they were on the same block as the fence (this is due to the fact that fence takes up less then a whole block). What I do for my underground farm is I have a single block 2 meters away from a 2 meter high wall like so:
= = = ======
sprint jumping off the block gets you to the top of the wall.
Hope this helps! -legacy
Just to update this since the fence problem has now been fixed and animals no longer glitch out through them, fences are easily the best way to do this.
To avoid the problem of pigs pushing their way out when I come in, a double gate system has always worked for me. This helps a lot because it keeps their pathfinding algorithm from "seeing" the opening. In the event one does pop through the inner gate, just push them back in before closing it and continuing on to the next one. A pressure plate on the outside of a gate will also automatically close it when you walk out, saving you a step.
For advanced users, try moving pigs around in minecarts to build more complex systems. Starting in 1.5 (the redstone update) farming will be getting a major makeover and many new things will be possible!