Pomodoro Clock code review

I’ve finished the Pomodoro Clock challenge and would appreciate a code review regarding my approach. Thanks in advance!

Major caveat: I am no expert and haven’t really learned how to do this effectively myself yet…

I think all of your embedded if statements would be a headache for another developer (or future-you) to maintain or develop.

As I understand it, it is ‘better’ to make your code up of smaller, easier-to-reason-about chunks, made up of small functions with sensible names.

That way it is easier to parse the logic in your head as you read it.

But I am a rank amateur, so take everything I say with a grain of salt.

I love the simplicity of the design. As a user, I’d prefer a reset button in there as well.

A reset button is easily doable, it is set up to reset when the session value is changed but no other hard reset exists as I was sticking fairly closely to the example design. I’m not a huge fan of nesting if statements too much either, and I can possibly refactor some of this out. Most of the if statements are used to edit the display, for example, when the minutes or seconds are below a certain value, additional 0s are added to the display.

Any recommendations are welcome! Thanks for having a look!

I just had a look at my old pomodoro and in the code I have a couple of comments basically saying // refactor this!

I’m still figuring out getting that kind of thing right myself. I re-read yours after I posted and thought that maybe I was barking up the wrong tree all-together, since I’m not sure how I’d do it differently, but I’m hoping one of the veteran programmers in the forum will chime in with “you can just do [ this thing ] and then get rid of 20 lines of code!” So I can learn what [ this thing ] is!

Exactly. I have a basic understanding of how to put the pieces together, but am interested in best practices, performance, etc. I know a lot of these things will come with time and experience, but having someone point me in the right direction will definitely help.

Oh, and I added a reset underneath the clock. :wink: