1) I have a little switch on my laptop that turns WiFi on. When I need to focus, I just turn it off. I only allow myself to turn it on if it's a development-related thing I need to do.
2) I use my down time (subway, boring classes, etc.) to work out what I need to do next. I start with a high-level todo of features then iteratively break them down to smaller pieces, usually going as detailed as function signatures and database table design. Not only does it make it easier to get work done once I get to the computer, but putting the design of a feature in the back of my mind for a few hours will usually bring out the design flaws before I write a single line of code. (My red pocket Moleskine works great.)
3) If I haven't done the feature design ahead of time, when I start a new complex method, I write the method as English comments, one step per line. After that, I write the implementation of each comment in code.
+1 on 2) and 3). In my case, unless the logic of the program is very simple, I always try make a sketch of what I am going to program before I start -- either on paper or text editor.
Of course, YMMV. Others will be more productive just plunging into the program head first.
2) I use my down time (subway, boring classes, etc.) to work out what I need to do next. I start with a high-level todo of features then iteratively break them down to smaller pieces, usually going as detailed as function signatures and database table design. Not only does it make it easier to get work done once I get to the computer, but putting the design of a feature in the back of my mind for a few hours will usually bring out the design flaws before I write a single line of code. (My red pocket Moleskine works great.)
3) If I haven't done the feature design ahead of time, when I start a new complex method, I write the method as English comments, one step per line. After that, I write the implementation of each comment in code.