code written during research is a complete mess, and necessarily so: you don't know what you're going to end up with. you try this, you try that, you hack it, you tweak it six different ways. often things only work in a few very specific situations; generalising to more useful situations can be difficult.
a phd won't motivate you. the right environment will educate you on the latest techniques though and teach you to be critical of them and improve them.
you'll also learn how to write code quickly---i find deadlines in academia more intense than my industrial experience (perhaps because the outcomes are far less predictable).
i wouldn't do a phd part-time:
1. it's intense.
2. you want it to be over as soon as possible.