Looking for some feedback on my calculator project


Hi everyone!

I think I finally have my calculator project in a functional state and I’d like to have some feedback. I know it “works”, but I’m not sure if my code is any good.

Here’s the calculator.

And here is a link to the github repo.

I realized that I’ve been learning in a vacuum and never really asking for feedback on my projects before moving on. So I want to work on being better about that going forward.

The main issues that I’m aware of currently are:

  • Global variables - Everything I read says global variables are a bad idea, but I’m not totally sure how to declare a variable within a function, and not have it reset every time that function is called. Should I make a function just to declare these variables, then pass them to the other functions that need them?

  • Function length - I know my captureInput function (starts at line 90) is pretty long. I’m still working on breaking this down into smaller functions. Any advice on that would be appreciated.

  • Comments and commits - I’m going to work on writing better commit messages and comments throughout my code. Is there an agreed upon process for comments? I’m not sure if I should be commenting as I go, or focus on writing the code first, then comment everything at the end. Right now I think I spend a lot of time deciding on how to word my comments/commit messages, and that knocks me out of “the zone” so to speak.

Thanks for reading! If anyone has any comments or criticisms, I’d love to hear them!