Hmm, that's an interesting (and important) question that I've never really thought about before. As far as discipline goes, I take the minimum distraction approach. My window manager shows nothing except the windows on the current desktop and the pager (i.e. no menu bars, icons, etc). For writing code I use Emacs (sans shortcut icon bar) and xterm. So I have very little visual distraction to attract my focus away from writing code.
As for motivation, I think the key is finding an interesting problem to solve. If you're programming for yourself, think about some tools that you would like to make life easier. (For example a scheduling program or automated FTP client or something.) Or look into some technologies you've always wanted to learn. (Maybe you think AJAX looks cool, or you'd like to learn GTK or QT.) If you're programming for someone else, and you have the leeway to do it, try to solve the problem at hand in the best and most interesting way possible. Say you need to modify the same line in 100 files. It would take a long time, but you could do it by hand. Or you could look up a sed tutorial online and get it done in 10 minutes, plus learn something in the process.
Both focus and motivation are mostly mind games that you play with yourself. These things work for me, but you may over time find other things that work better for you.
|