My work process goes like this:
0. Talk to or get instruction from someone who understands the problem
1. Understand the problem yourself
2. Think about how to solve it
3. Solve it
4. Go back and clean up the code (making it production ready)
5. Repeat 4 if necessary
Eventually, you learn and get good practices in memory that you can start writing production code before you ever get to step 4. This is how I see developers gain experience