• ryan@the.coolest.zone
    link
    fedilink
    arrow-up
    131
    ·
    1 year ago

    Let him play in the legacy code. You can just hose him off later before letting him back into the office so he doesn’t track it everywhere.

    • ISometimesAdmin@the.coolest.zone
      link
      fedilink
      arrow-up
      60
      ·
      1 year ago

      Unfortunately if you let Junior play in legacy code once, it’ll learn some nasty habits and make more of it from scratch, usually when you’re trying to sleep.

    • BaardFigur@lemmy.world
      link
      fedilink
      arrow-up
      11
      ·
      edit-2
      1 year ago

      How do you even fix it, when the design is broken. Sure you can make an alternative function, without all the warts, but how do you convince the “seniors” to not use the old functions, because it is in fact problematic for various reasons.

      We have a separate C-library that returns all strings by ringbuffer. Why is that a problem? Call into the ringbuffer enough times, and it will wrap around, overwriting earlier strings. This, and other bad code practices such as broken multi-threaded code (not threadsafe), and more.

      • CodeMonkey@programming.dev
        link
        fedilink
        arrow-up
        9
        ·
        1 year ago

        If you are creating an alternative implementation and leaving the old one in place, you are not fixing a problem, you are just creating a new one (and a third one because you have duplication of logic).

        Either refactor the old function so that it transparently calls the new logic or delete the old function and replace all the existing usage with usage of the new one. It does not need to happen as a single commit. You can check in the new function, tell everyone to use it, and clean up usage of the old one. If anyone tries to use the old implementation, call them out in a code review.

        If removing or replacing the old implementation is not possible, at least mark it as deprecated so that anyone using it gets a warning.

        • BaardFigur@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          1 year ago

          It wish it was that easy. It is a deep rooted problem, because of several other factors.

          There’s not just one function that is l dependant on the ringbuffer, but multiple functions in multiple libs and dll’s. Some if these dll’s and libs are used by us, some are used by another department and some are used by both. It has to stay C-code, in order for both departments to be able to use the library. The other department is using pInvoke to call it from a C#-application, or from other dlls. We use it as library in a C+±application, but also for us it might happen indirectly by being called from other libs or dlls. A proper fix is therefore an immense task, and requires coordinations between multiple teams.

          About deprecation, well, we handle warnings as errors, so adding a deprecated-attribute wouldn’t compile. I could add a warning-assert, but that annoys some of the senior developers, and then I have to remove it again.

          About code review, many of the seniors often don’t do them and just commit directly…

          To sum up, it’s easier to phase it out instead of turning everything upside down.

  • Bappity@lemmy.world
    link
    fedilink
    English
    arrow-up
    51
    ·
    edit-2
    1 year ago

    me when first starting out at a job commenting everything I can
    VS
    me a couple years in completely lost because I never updated the comments and now none of them make any sense whatsoever

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      56
      ·
      1 year ago

      Commenting well is a highly advanced skill. I generally prefer no comments on code since it’s less likely to confuse people and I’ll merrily purge auto-doc comments and anything like

      // getId() returns an id

      That comment has negative value.

      • kubica@kbin.social
        link
        fedilink
        arrow-up
        23
        ·
        1 year ago

        I can’t help it, I always get the mental image of hands clapping sarcastically when I see something like that.

      • Platypus@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        9
        ·
        1 year ago

        In my experience refactoring lots and lots of crappy code left by devs long gone, a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them. If the code doesn’t have informative names and clear separation of concern, chances are a comment won’t help because the dev didn’t really know what they did that worked in the first place.

        • MagicShel@programming.dev
          link
          fedilink
          arrow-up
          14
          ·
          1 year ago

          Generally, yes. However I have been known to document exactly why I’m doing something incredibly stupid - because it’s required but a stupid third party library which, despite being awful, is still better than implementing it myself as a refactor.

        • Bappity@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          1 year ago

          a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them.

          my boss is great in this regard and also always has to keep reminding us to write unit tests 😅

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          18
          ·
          1 year ago

          The best explanation I’ve ever heard is:

          Comments should state the ‘Why’ never the ‘What’.

          • hikaru755@feddit.de
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            There are some cases though where the code is just complicated for reasons outside of your control, in which case “what” comments are good - but they should never be taken at face value, but only used as a first step in understanding the code. There’s a significant risk of the code not actually doing what the comment says.

        • dukk@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          Yeah. Most of the time I use comments in my algorithms, as they often use some weird optimized black magic which are difficult to understand without comments.

      • Solar Bear@slrpnk.net
        link
        fedilink
        English
        arrow-up
        6
        ·
        1 year ago

        I write a lot of fairly simple scripts in Bash and PowerShell that should be easily understood by anybody else with moderate experience in the language, but I leave a lot of obvious comments because my coworkers don’t write any code and are extremely skittish about my automations. I add them basically to quell their fears.

          • Solar Bear@slrpnk.net
            link
            fedilink
            English
            arrow-up
            5
            ·
            edit-2
            1 year ago

            These are scripts that manage stuff on a few hundred user endpoints and a few servers. They were doing basically everything manually until I got here, and the only way I could get them on board with my slow introduction of automation is to let them see it. I have to ensure things don’t get too long, complex, or hard to explain, or they start getting nervous.

      • oce 🐆@jlai.lu
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I’d rather teach people to comment well through my reviews. Much easier to understand two lines of well written function description in English than 20 lines of code.

  • magic_lobster_party@kbin.social
    link
    fedilink
    arrow-up
    27
    arrow-down
    1
    ·
    1 year ago

    There’s also that long time senior dev who’s overly confident in their abilities and force pushes production breaking code directly to master.

  • ericbomb@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    1 year ago

    Look, it’s me.

    Just let me rewrite ONE report from scratch so it doesn’t check a specific unindexed table that it doesn’t actually need to check and causes the report to be killed by MSQL because it takes too long to run.

    Please just one rewrite. Please.

    Just one little crystal report.

    • justJanne@startrek.website
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      Often enough, the old code is so badly intertwined that it’s impossible to actually test. Those are the moments where all you can do is nuke it from orbit.

      • XTornado@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 year ago

        Well I was going for that… They will surrender before they do any changes.