I'm going to cite this article again because I think it's relevant to the question:
https://www.gapingvoid.com/blog/2023/06/13/where-do-insights-come-from/
The article lists three main sources of insight—and as I said in another
thread, insight and creativity are closely related:
1. Creative desperation - where you realize that there's a belief or assumption that's limiting your thinking and you decide to discard that belief or assumption.
2. Connections - where you see
patterns and relationships and figure out how things fit together.
3. Contradictions - where you see a pattern that doesn't quite fit together.
All these resonate with my experience as a programmer and I could cite many instances where I had to be creative because of these things. For me, refactoring gives me many opportunities to get creative. Also, design is a very creative activity. If you're a programmer,
you should always be experimenting, designing, and refactoring. In other words, if you're a programmer, how can you NOT be doing anything creative? Pretty much everything we do as programmers is creative.