Javier makes a good point that changing requirements are a tough fact of life. I too get frustrated by these situations as too often I find myself working on a product where the developer has to make decisions. My opinion used to be "Why can't management figure this out with the client?", or "Why did we begin this project if the client doesn't know what they wanted?", "It's so much headache when they change so late in the development".
Simple fact: this will always happen, not just in programming / software development but in every walk of life. The world would simply be a very boring and very different place if people never changed their mind, never adapted, never addressed change. People have a tendency to look at what they're given, and improve it. Do you not do the same thing with your code? If I have a block of code which I'm not happy with (it's inefficient, messy), I will improve it. (Does the operating system complain at me? ...sometimes, if I'm using a certain unnamed OS, but generally not)
As programmers we need to grab opportunities to improve things, and not get depressed or annoyed by them. Take the opportunity to talk to people, improve your style, improve your work ethics, approach things with an open mind, push yourself to be better than you were yesterday. Move forward in your career and don't settle too easily.
I understand that not everybody will agree with this answer but I think it's important that the answers to this question cover a wider perspective.