Yep. This is the way. Even if you don't want to/are not able to have a daily routine and such, detaching as many activities as possible from volatile things like motivation,mood,etc is extremely useful. That is the most important part. Early on in life it is easy, since you have a clear set of objectively great things to do - do great in school, do great in exams, do great in college, get a great first job, don't screw up health in growing years. So you can force yourself to do those no matter what. Later on in life (post college) it gets harder, since you have to ensure you're not forcing yourself to do something counterproductive, especially in new fields like SWE, where there's no clear industry standard career path yet, or an industry standard anything really. Academia in contrast you can apply this strategy until a lot later.