Coffeey, I (no offense when I say this) doubt that they despawn. There are times, in November - December, where I wouldn't be on for 2-3 weeks in a row. My sheep and chicken never despawned during that time.
And so 1337's idea is supported, I have used a similar approach. My first layer of perimeter block is smooth stone block. Then I do 2 high of glass, then a stone block on top of that. Horizontal with the top stone block, you put a dirt roof. Make sure that the walls are two units thick. So you'd have a wall with two stone block thickness on the first unit high, and the next two up are two thick of glass, then two thick of stone on top of that. My animals never glitched into the wall. Namely because you can't suffocate in glass (I'm not sure why that is, but it just is, so I've read, and it works). For chickens, you can subtract one glass height (since they are smaller than a single unit). But yes, if you want the farm look you should put fence post on top or something. I just made a sheep sky scraper and a chicken sky scraper (11 levels of sheep, haha, and 5 of chicken).
And so 1337's idea is supported, I have used a similar approach. My first layer of perimeter block is smooth stone block. Then I do 2 high of glass, then a stone block on top of that. Horizontal with the top stone block, you put a dirt roof. Make sure that the walls are two units thick. So you'd have a wall with two stone block thickness on the first unit high, and the next two up are two thick of glass, then two thick of stone on top of that. My animals never glitched into the wall. Namely because you can't suffocate in glass (I'm not sure why that is, but it just is, so I've read, and it works). For chickens, you can subtract one glass height (since they are smaller than a single unit). But yes, if you want the farm look you should put fence post on top or something. I just made a sheep sky scraper and a chicken sky scraper (11 levels of sheep, haha, and 5 of chicken).