Coding on metros, trains, buses and planes is exactly the reason I always make sure my dev environments work 100% offline, with dummy services in place of the real ones.
One thing I love about coding on public transport is the sense of urgency can be fun.
Being on the verge of figuring out a bugfix or whatever when you know train is pulling into the station and you have maybe a minute to go, cracking it, quick test, bundle the laptop quickly back into your bag as you step off the train is quite a nice feeling.