As my co-worker always used to say:
- Make it work !Make it work
- Fix all bugs make it work flawless!Fix all bugs make it work flawless
- Apply optimizationMake it S.O.L.I.D.
- Apply optimization if it is performing slow
In another words, always keep in mind KISS (keep it simple stupid). Because over-engineering, over-thinking some code logic may be an issue to change logic next time. However, keeping code clean and simple is always good practice.
However, by time and experience you would know better which code smells and would need optimization pretty soon.