Some time ago I found a quotation by Buckminster Fuller:
When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong.
Although Fuller had many titles – architect, author, designer, futurist, inventor, visionary - none of them was a programmer. Yet I believe this quote is an excellent representation of our work.
The initial approach when coding must always be to pursue functionality. Correct functionality, of course. And then when finished, if we have kept good programming practices, the aesthetics of the code itself will be noticeable.
Otherwise, we have failed.