0

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

3
  • see Why do 'some examples' and 'list of things' questions get closed? Commented Jul 29, 2023 at 11:31
  • 2
    Effective Programming is like learning how to play an instrument: you don't learn it by following just 5 principles, you learn it by practicing it a few years. Commented Jul 29, 2023 at 11:40
  • 2
    These are great questions, but the whole field of software engineering is about solving these problems! There is no simple 5-point answer to how to write bug-free easy-to-maintain code. The best advice is probably "keep it simple", but that is not necessarily easy to do. Commented Jul 29, 2023 at 11:46

1 Answer 1

2

I would like to spend more [time] doing what I'm good at - the math and stats - and less of it on what I'm not as skilled at - organizing code.

The problem is that you're not being employed to do maths and stats personally, you're being employed to configure a computer to do so, and to some extent, tell other people how to do so.

That need for constantly externalise and reproduce your understanding - not just to produce your own understanding internally - is the root of the challenge.

This isn't a skill limited to coding, but to any research or educational activity.

I'd suggest to begin by thinking about the difficulties within these terms.

1
  • 1
    Thanks for the advice - I hadn't thought about it that way but I can see your point and that makes a lot of sense Commented Jul 29, 2023 at 12:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.