This question may get closed quickly, but I'll appreciate any advice I can get and all the resources I can find online about this topic aren't quite relevant to my case.
I am a Math PhD student doing an internship that requires me to do a lot of machine learning. From my background, the algorithms and statistics are reasonably straightforward. What isn't straightforward to me is how to keep all the code organized so that it's easy to change things without having to spend hours/a day refactoring everything and debugging the errors I introduced.
For instance, I've got some classes for: loading data, preprocessing data, training models, evaluating them, and producing a report on how that model did. Sounds fine - but the models I'm working with keep changing in ways that mean I need to add some new functionality pretty much every day or two (so far).
This means I end up wasting time chasing down dumb errors like "I made a typo" or "I'm getting confused about whether or not I need to make a new class what I'm trying to do."
I also have limited time left in this internship and I would like to spend more of it doing what I'm good at - the math and stats - and less of it on what I'm not as skilled at - organizing code.
My question is: Can you give me your top 5 principles/resources/tricks so that I can:
write code that I ideally shouldn't have to change, but it would be easy to do if I needed to
Stop making stupid mistakes
Be able to debug something without it taking a long time
For instance - if I need to add some functionality that is adjacent to an existing subroutine I have, should I try to add it to that subroutine or should I just write a new subroutine?
I realize this might get closed so if anyone would be willing to message me with advice please do so. It would also be helpful to know if this just comes with the territory and will get better with experience since I feel like a moron