For a while now I’ve had the problem of rearranging my application windows whenever I connected or disconnected my MacBook to a display. I first had it with my 15” MacBook Pro to a 24” Cinema Display back in 2010 and now have run into the same problem after getting a 13” MacBook Air and the 27” Cinema Display.
For a while I just used window snapping or arranging tools which allowed me to use keyboard shortcuts or drag-n-drop to arrange the windows by size and position. This was fine but still meant I had to do it every time I connected or disconnected, since I do this twice a day minimum it started to get frustrating.

I’ve now found what seems to be a pretty full proof solution to this, although slightly pricey for my taste. Stay is a menubar application which allows you to record the positioning of windows per display size. That means it detects the display resolution you’re using and arranges the windows how you saved previously. The price of $14.99 is steep but worth it if you connect and disconnect a lot I suppose.
I have experienced an issue with Google Chrome automatically being restored to the correct size and position. So far this is the only application I’ve found which doesn’t, but I simply use Window Magnet. Again it’s a tad pricey at $4.99 but worth it for originally arranging your windows into various sizes and positions.