• dejected_warp_core@piefed.world
    link
    fedilink
    English
    arrow-up
    31
    arrow-down
    2
    ·
    14 hours ago

    Speaking of coding out of spite, is nobody going to mention that his C code features a struct with over 20 fields in it?

    • wheezy@lemmy.ml
      link
      fedilink
      arrow-up
      18
      ·
      7 hours ago

      Oh man. You should see the source code for IOS (the Cisco one not Apple).

      Spent 5 years working on it out of college. I think it’s the most cursed code base you can imagine.

      Not necessarily because of the massive struct defs everywhere. They are kinda needed when you’re running an entire OS as basically a set of interacting Linux processes pretending to be an OS.

      At some point Cisco realized they could not compete without putting a Linux kernel as their base. So they basically just copy and pasted the old code written in the early 90s for the IOS and put it into a set Linux processes.

      To be clear. It’s not just the front end. They didn’t really change the code much from the old IOS. Its a cluster fuck of interprocess communication hacks that probably seemed like a good idea at the time.

      It is a massive pain in the ass to code because you’re basically doing everything on the Linux kernel and then frustratingly have to write the CLIs for IOS just so Cisco can continue to sell their proprietary OS with some of the most unnecessary hardware locks. Massive learning curve for any new engineer.

      Literally, no one on the entire switching team knew how to send a message from a specific process to the IOS process. I had been assigned something that needed it. So I somehow figured it out and was “the guy” for that for the time I spent there.

      Fuck. I’m gonna start ranting more if I go any further. But yeah, sometimes you need a massive struct because some idiot decided that forcing a closed source CLI on the market is a good idea for profits.

      Definitely not a good idea for coding. But you learn quickly that no one actually cares about good code in this industry. There is no time for it. There is no reason for it. Just spit out garbage until it works and your manager won’t care.

      If you want clean code. Go write an open source project or a personal project.

    • calcopiritus@lemmy.world
      link
      fedilink
      arrow-up
      27
      ·
      12 hours ago

      Sometimes you can’t not have a god class (struct in this case). When doing UI specifically, I always end up with one.

      You can try using encapsulation to reduce the amount of fields technically, but in the end it’s the same amount of information in a single god class.

      • qqq@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        13 hours ago

        Not really, but I’d probably try to organize those into sub structures where it made sense. A data structure holding the UI state and FFT data all flat is kinda messy imo since it becomes unclear what is actually required where.