• Successful_Try543@feddit.de
    link
    fedilink
    arrow-up
    21
    arrow-down
    1
    ·
    9 months ago

    I’ve once had a course involving programming and the lecturer rewrote the code, which we were usually using at our institute, making ALL variables global. - Yes, also each and every loop counter and iterator. 🤪

    • Chriszz@lemmy.world
      link
      fedilink
      arrow-up
      18
      arrow-down
      1
      ·
      9 months ago

      There’s no way you teach a uni course and do this kind of thing unless to demonstrate poor practice/run time difference. Are you sure you were paying attention?

      • Successful_Try543@feddit.de
        link
        fedilink
        arrow-up
        17
        ·
        edit-2
        9 months ago

        Yes. He really thought it was efficient and would avoid errors if literally all variables were defined in a single Matlab function he called at the beginning of the script. We students all thought: “Man, are you serious?” As we didn’t want to debug such a mess, in our code, we ignored what he was doing and kept using local variables.

        • Chriszz@lemmy.world
          link
          fedilink
          arrow-up
          23
          ·
          9 months ago

          Ah I misread I thought it was specifically a programming course. I can expect this from a math prof.

          • Successful_Try543@feddit.de
            link
            fedilink
            arrow-up
            8
            ·
            edit-2
            9 months ago

            Yes, it was a course on finite deformation material models. And no, you do really, really not want to declare each and every variable in your material subroutine globally for the whole finite element program.

          • Techmaster@lemm.ee
            link
            fedilink
            arrow-up
            3
            ·
            9 months ago

            That’s why when your job hires new people right out of college they have no idea what they’re doing and now must be trained how to actually do the job. “What, you mean we aren’t writing this enterprise application in python!?”

      • rtxn@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        9 months ago

        I’ve seen two teachers do this, both of them mathematics professors who teach programming for the extra cash. One uses C, the other Pascal.