I’m studying programming, and I don’t agree woth my teacher. She basically said that if we use break (and continue too maybe) our test is an instant fail. She’s reasoning is that it makes the code harder to read, and breaks the flow of it or something. (I didn’t get her yapping tbh)

I can’t understand why break would do anything of the sorts. I asked around and noone agreed with the teacher. So I came here. Is there a benefit to not using breaks or continues? And if you think she’s wrong, please explain why, briefly even. We do enough down talking on almost all teachers she doesn’t need more online.

  • Redkey@programming.dev
    link
    fedilink
    arrow-up
    12
    ·
    1 year ago

    Assuming C/C++, dare we even ask what this teacher uses instead of switch statements? Or are her switch statements unreadable rat’s nests of extra conditions?

    This is a good life lesson. We’re all idiots about certain things. Your teacher, me, and even you. It’s even possible to be a recognized expert in a field yet still be an idiot about some particular thing in that field.

    Just because some people use a screwdriver as a hammer and risk injuring themselves and damaging their work, that’s not a good reason to insist that no-one should ever use a screwdriver under any circumstances, is it?

    Use break statements when they’re appropriate. Don’t use them when they’re not. Learn the difference from code that many other people recommend, like popular open-source libraries and tutorials. If there’s a preponderance of break statements in your code, you may be using a suboptimal approach.

    But unfortunately, for this course, your best bet is to nod, smile, and not use any break statements. Look at it as a personal learning experience; by forcing yourself sit down and reason out how you can do something without using break statements, you might find some situations where they weren’t actually the best solution. And when you can honestly look back and say that the solution with break statements is objectively better, you’ll be able to use that approach with greater confidence in the future.

    • gazter@aussie.zone
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      It’s a very good lesson- to the point where I wouldn’t be surprised if the teacher is deliberately putting an arbitrary restriction on the assignment.

      If you want to have a career, the people that pay you are going to make you do things that you consider to be ridiculous. That’s work, that’s life. You’ve got three options- Just smile and nod and do it their way, get huffy and tell them that you don’t like their yapping and you’ll do their project your own way, or politely suggest there may be an alternative way, and ask if they are willing to be flexible with some requirements.

        • UnRelatedBurnerOP
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          You guys have so much faith it’s contagious. Very motivational words, Thank you.

      • UnRelatedBurnerOP
        link
        fedilink
        arrow-up
        1
        arrow-down
        2
        ·
        1 year ago

        I’ve never considered that she might just be very smart. You’re very optimistic. Filled me with hope out of nothing. Thanks!

    • UnRelatedBurnerOP
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      last part gave me something of a mindset change, for the better. I’ll try being a little less of an idiot then c: Thanks!