1. Write It Out Before You Code
Keep a habit of scribbling out the algorithm/pseudo-code before you actually convert the solution into code. Writing by hand can also help you plan your code before you move it to the computer. You can save a lot of time if you write out which functions and classes you will need, as well as how they will interact. Although more time consuming, this restriction will mold you into a more fundamentally sound developer.
2. Keep a Checklist of Tasks
When you are implementing a feature, its always good to split the bigger tasks into smaller and clearer tasks which are individual logical units and can be tested individually. Keep a list of such small achievable tasks and keep ticking against them once you complete it. This will give you a boost and motivate you to keep ticking more boxes. The checklist can be either in a book or in any software (like Google Keep).