I have been working in the IT industry for the last 13 years and I was diagnosed with ADHD around two years back.

As part of my job, I have to look at a lot of code. It used to be that I used to write a lot of it, but recently since getting promoted, my work now revolves mostly around reviewing the code others wrote or sometimes enhancing someone else’s code.

The problem comes when I come across some extremely convoluted legacy code. For example, like a function hierarchy with 10+ levels of function calls across several hundreds of lines. This causes me some problems understanding what’s going on because it’s nearly impossible for me to follow every branch to understand which part of the code needs fixing. After a while traversing the function calls I often forget how I got there and have to retrace my steps (I use debug breakpoints but it doesn’t help much). I also tend to get distracted with ideas of how to re-implement the whole thing with best practices rather than focus and work on delivering the fix that I am expected to do. This severely hampers my turnaround time and I’m sure my supervisors are frustrated.

What baffles me, however, is that my other colleagues look like they have no problems working on this codebase. So I cannot really blame the badly written code before my supervisors.

So I just wanted to ask anyone here who has ADHD, works in IT/Software Engineering how do you cope with a situation like this? Also, does medication help here?

I used to be on Atomoxetine, but after experiencing a nasty anxiety attack, I stopped about a month ago. Not that I observed any major improvements while I was on it.

PS: Apologies if the context does not make sense to any of you non-IT folks. I can clarify if you ask.

  • Radioactive Butthole@reddthat.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 hours ago

    I find a nonlinear note taking app like Obsidian or Logseq to be helpful when I need to organize large amounts of information. Links and tags make it easy to traverse large amounts of data quickly, and since I link and tag however tf I want, I can usually follow my own thought process to rethink something if I have to.

  • entropicdrift@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 hours ago

    Ironically these types of tickets are kinda my ADD superpower. I hyperfocus on understanding the entire flow until I fully understand every possible way the bug could occur, then fix it.

    It’s when I’m trying to plan something from the ground up that the writer’s block hits me and I fall into procrastination and infinite rabbit holes till pressure is applied externally.

  • Test_Tickles@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    6 hours ago

    I don’t know about intellij, I have worked mainly in VS Pro. I will tell you some of The things I can do in VS that help and then I’m sure intelliJ probably has similar functionality or plugins that will add it. Check to see if you can generate call graphs or call maps. VS enterprise has the ability to add each function to a graph and build up a diagram for you. Unfortunately pro and standard do not.
    Ctrl + “-” will jump back to last. This allows you to reverse through the call tree.
    You should be able to display a call stack that at least tells you how you got down to where you are.
    Make notes about reimplements you want to make and move on. Sometimes just writing it down so you won’t forget is enough for my brain to let it go.
    In VS Pro you can create a break point and then right click on the red break point dot and add conditions and\or actions. Conditions stop it from breaking there unless a condition is met, this is great when you only want to catch one iteration of a loop. Actions are something that will be evaluated and done like printing out information “$FUNCTION, myvar {my var}” will print out current function name, myvar, the value of myvar". You will be surprised how complex of a variable it will print. For instance it may print out an entire structure or contents of a class. You can then set the action to not break, that way the code performs the action and keeps going. Doing this will allow you to generate as detailed a list as you want of breakpoints in the order in which they get hit plus any variables you want to track.

  • MasterBlaster@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    9 hours ago

    Others have covered this well. From my experience (35 years), most “developers” write stream of thought code. It reflects how their brains process, without regard to others. When I have agency, I can steadily refactor the code to reduce indirection, nested if.then, etc. When I don’t, I’m in danger of being too slow in completing the work. Just lost my job for that reason while working with a 1000 line service entry method with a cyclomatic complexity of 310 and 34 class parameters. Coupled with being the acceptance tester as well, it makes it near impossible to succeed.

    For extremely complicated code I used to create simple diagram sketches that illustrated the dependencies. It acted as a series of bookmarks to help keep my place. I think I have a smaller “working space” in my mind than non ADHD programmers. I think they can keep all that complexity in their mind at once while I cannot.

    In a way, I turn that into an asset by writing code that I can reason about, which by definition requires it to be SOLID, and with minimal responsibility per function.

    Lately, I’ve been using AI to generate sequence and class diagrams of the code to act as a high-level view of what’s going on. Major time saver.

  • orca@orcas.enjoying.yachts
    link
    fedilink
    English
    arrow-up
    12
    ·
    12 hours ago

    Dev with 18-20 years of experience. I was originally diagnosed in the 90s. Stopped taking meds (Atomoxetine) recently because I hated how they altered my mood.

    It’s not just you. Your colleagues probably have the same struggle but it just hasn’t been talked about yet. Any time I’ve brought up a gripe about something, I’ve always had colleagues chime in and agree. Any time I have to traverse complex code like that, I have to have like 5 panes open in VSCode and sometimes I have to take rough notes, or diagram it out.

  • Erik@discuss.online
    link
    fedilink
    English
    arrow-up
    9
    ·
    12 hours ago

    Skim the book, “working effectively with legacy code”. In a nutshell, you write characterization tests around the module or method, then do safe IDE based refactorings, then do some slightly more significant refactorings. After that the code should make enough sense for you to make changes if you need to.

    It is as much in art as a science. The important thing is that as you are doing refactorings, the main one you do is to extract methods, and give the methods clear names that say what they are doing. You should be left with a top-level method that reads like a narrative of what the whole thing does.

    Medication helps me quite a bit. I am also using Atomoxetine. The effect is much more subtle than stimulants, but I think just as powerful in the long run.

  • CompactFlax@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    12
    ·
    14 hours ago

    I have a suspicion that a lot of people, when faced with this problem, just say “Sure, looks good to me. It’s legacy, so it’s been working forever,” and carry on with their day.

    But - I could be mistaken.

    • deathmetal27@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      14 hours ago

      Until you have to fix some bug some dude introduced seven years ago and is no longer working at the company.

  • KeenFlame@feddit.nu
    link
    fedilink
    English
    arrow-up
    2
    ·
    10 hours ago

    Taking amphetamines improves this ability and can fix your issue. But the reason, is because you don’t enjoy this as much as writing code. You enjoying what you do gives you executive power and control over what you focus on, and getting more money is not something that allows you to overcome this, if it’s not stimulating, it’s not as easy for you to do it. This comment is sponsored by by amphetamine.

    Jk but I took the route of doing what I love and damn the money. I have to use what dopamine reserves and energy I have on other things in life, household and stuff, and if both drain me I am not as capable as if I adjust my priorities. And I have kids so it’s not hard to choose really. I still count this as a blessing, since when I do stuff I love and they don’t bore me, I can enjoy hyper focus and productivity, and then have energy for life too

  • Scratch@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    6
    ·
    13 hours ago

    For me, I’ll hop onto a new git branch and start renaming functions and variables to what they actually do.

    I might drag some blocks of code out into new functions, just a real rough refactor to get both the flow and my understanding of each block in place.

    Big if conditions get their own function, named what the intent is.

    I work in Xcode, so we can add extra context to breakpoints. I recently discovered the bookmarks that are built in, and you can annotate them too!

    Make a change, start from the top and make sure it reads ok and still makes sense.

    It’s eating an elephant on repeat.

    • deathmetal27@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      12 hours ago

      Yeah, I use bookmarks and mnemonic bookmarks as well.

      Creating a rough git branch is a good idea though, I should do that. Currently, I try not to modify the code too much when studying so that the code because I would later have to revert them back otherwise it would confuse the PR reviewers if there are too many formatting changes not relevant to required changes.

  • Infynis@midwest.social
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    14 hours ago

    I don’t work in software, but networking, where I often have to work in CLI for configurations on multiple devices simultaneously. What I’ve been taught, and what’s worked for me, is drawing logical diagrams by hand with pen and paper when I’m working in a system that I think has the complexity level to get lost in. I don’t know for sure how well that will translate to software in general unfortunately.

    Where that line is varies person to person, so you might only do it for those weird legacy systems. That’s usually how it is for me. This is how I best understand things in general. Laying them out physically in front of me and writing it all by hand in the format that I Intuit really helps me keep track of exactly where I’m working on what

    • deathmetal27@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      14 hours ago

      I tried doing that, except instead of drawing diagrams of the flow of execution, I write down a gist of what I understood after reading a couple of lines. It’s still pretty hard to do because interpreting what something does is hindered by things like function or variable names often don’t always align with their actual purpose or even not adequately descriptive either. I often find myself muttering “Why the fuck is this written this way.”

      I guess legacy code is the bane of everyone with ADHD.

  • PiJiNWiNg@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    11 hours ago

    I’m an admin not a dev, but when writing complex scripts, I found using a whiteboard essential to lay out high level workflows.

  • pannenkoek@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    12 hours ago

    I have ADHD and in software engineering. I was also diagnosed recently… around a year ago. Disclaimer: I have around 20 years of experience.

    Since I take my medicine I notice that I am way more precise than before and that I am not rushing things anymore. It’s absolutely insane how many sloppy mistakes I made before and how much my code quality improved overall. I am now deeply ashamed how much of a pain in the ass for my colleagues I must have been before :p

    Anyway: What makes the difference for me: taking the time to think about proper solutions. Let some problems rest for a day and reevaluate the things I made the day before, before review, merge or deployments.

    Back to your original problem: legacy code like that is probably hard for everyone but it makes a difference in what pace (or patience!) you are doing your work. I think medication can help you with that :)

    • deathmetal27@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      11 hours ago

      Anyway: What makes the difference for me: taking the time to think about proper solutions. Let some problems rest for a day and reevaluate the things I made the day before, before review, merge or deployments.

      I agree, I do this when I am designing some new module. I tend to write detailed design documents, covering as much behaviour as possible. I then get it reviewed by someone who might have a good understanding of the business process related to the change. This is not very feasible for legacy code because often there is no proper documentation or comments. What I’d prefer in such cases is to implement new modules in a manner where it lies somewhere outside the legacy body of code (different package or module) and expose functions to hook into the legacy code. This way at least the new enhancements follow best practices and don’t become just another patchwork to the increasingly unmaintainable legacy code.

      Back to your original problem: legacy code like that is probably hard for everyone but it makes a difference in what pace (or patience!) you are doing your work. I think medication can help you with that :)

      True. I have been thinking of resuming medication myself.

  • LuxSpark@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    12 hours ago

    I personally doubt many people are good at this, ADHD or not. Anyway, logging is the best way for me to “see” what’s going on. If you can output the name of the functions when they are called, you can see the order of what’s happening. Then, hone in on certain areas and add more landmark output statements to show major steps and intermediate results until you locate the problem.

    Meds can help the focus required to stick with this tedious process. Logging is a great tool, and even better if you take the time to make it configurable.

    • deathmetal27@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      12 hours ago

      I avoid adding logs because after I’m done, I will have to remove them otherwise my PRs will be very big depending on how many files I have to update. I instead track the call hierarchy of the function I am studying using a feature in the IDE. It basically creates a tree of all functions called by a function, which helps me track how deep I am and how I got to where I am currently.

      I should probably resume my medication though.

      • LuxSpark@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        2
        ·
        11 hours ago

        That’s cool, is it visual studio? I guess it depends on the system, but if you have good log files, you or anyone can troubleshoot problems without even looking at the code.

  • FreeBird@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    13 hours ago

    Hi, I am a newbie coder who works on open source projects as a hobby. I usually take notes or draw diagrams of how do the things work.

  • merthyr1831@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 hours ago

    I feel this as a mid level dev of 3 years lmao. Maybe straight up ask your supervisors for feedback but im sure some of your thoughts are imposter syndrome rather than genuine poor performance.

    If you’re working on a legacy codebase it might even be worth using that knowledge to lobby for technical debt sprints to actually deal with the issues you’re running into. I don’t believe for a second that it’s a problem unique to yourself (though some are weirdly adept at it!)

    Good luck pal, it’s a pain for sure