That is not entirely true, and over the last little while I've come up with a few scenarios where I will be writing code:
- Open-source software - I still have no problem with submitting patches to open-source software, or creating my own open-source works. While I don't believe that users of open-source software should be required to give back to the community, I do think that if I'm using the fruits of all their hard work, it's only fair that I give something back now and then. But that's a personal philosophy, and I will not tell others to do the same.
- Coding for myself - this has a bit of overlap with the previous one, since contributing to open-source helps fulfill some personal obligation or whatever you want to call it, or it helps improve the tools that I use every day, so you can say that any open-source contribution I make is basically coding for myself anyway. However this point is more for non-open-source projects I may undertake. For example, if I should decide to start my own business that uses some kind of software, it's likely that I will be writing some code. Should the healthiness of the business depend on others not having the software, then I will likely keep it proprietary. However patches and tweaks I make to open-source software that I use would be contributed back (well, they'd have to be if it were a GPL'd library).
- Small Contracts - this is the main confession I have to make. I don't like coding sites for other people's business, mainly because they usually aren't a business I'm really all that interested in, nor do I have much stake in the gains of the business. However at the moment I am a student. Other people have money; I do not. So small contracts are a good way to get a few bucks on the side to help pay for food and rent. Since people giving out small contracts usually don't care too much whether you like their work or not provided you do a good job, there isn't really any issues with my actual sentiments towards the work.