Sometimes, more so in my early-mid 20s, I would dream about code/architecture issues I was having, and bizarrely, wake up with the solution. It was a trip when I realized what had happened, so I started napping when I got stuck and it actually worked a decent amount of the time.