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.

@[email protected]
link
fedilink
English
5
edit-2
2d

The last task I got from my boss had a Jira ticket headed with “THIS CODE IS BAD. FIX IT BUT DO NOT REFACTOR IT”.

Yeah, I have a reputation.

But it would be better if my coworkers didn’t write garbage.

@[email protected]
link
fedilink
English
202d

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.

@[email protected]
link
fedilink
English
152d

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.

@[email protected]
creator
link
fedilink
English
42d

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

Radioactive Butthole
link
fedilink
English
42d

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.

Erik
link
fedilink
English
92d

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.

@[email protected]
link
fedilink
English
42d

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.

@[email protected]
link
fedilink
English
8
edit-2
2d

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

@[email protected]
creator
link
fedilink
English
62d

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.

@[email protected]
link
fedilink
English
52d

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.

Scratch
link
fedilink
English
62d

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.

@[email protected]
link
fedilink
English
22d

This is such a good idea, thanks for sharing!

@[email protected]
creator
link
fedilink
English
32d

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.

@[email protected]
link
fedilink
English
32d

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

@[email protected]
link
fedilink
English
42d

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.

@[email protected]
link
fedilink
English
3
edit-2
2d

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.

@[email protected]
creator
link
fedilink
English
22d

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.

@[email protected]
link
fedilink
English
22d

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.

@[email protected]
creator
link
fedilink
English
22d

No, IntelliJ IDEA. I do add a lot of logs in my own code though.

@[email protected]
link
fedilink
English
12d

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.

@[email protected]
link
fedilink
English
22d

Hello there, I’m a senior level dev former manager specialized in database shit.

It can absolutely be difficult to trace complex misleading function calls but part of the emphasis in coding should be readability and expressiveness (personally my opinion is that the highest cost in software development is maintenance and difficult to comprehend code multiplies this cost). If something is so complicated that, while it’s being written, it can’t be comprehended then that’d be a huge red flag for me and I’d likely leave comments on the review asking for the code to be better labeled (either better variable/function names, comments, clearer division of class/module responsibility) and refactored. This may not be possible pushback to give in your organization (which would be a big company red flag) but if you have difficulty comprehending it now you’ll have a lot of difficulty in the middle of an incident.

For me personally, I “trust” code labeling to help minimize the scope I need to keep in my head at any given time. If there’s a call out to saveFileToS3() I won’t inspect it now, I’ll just trust it does what it says on the tin and keep my scope limited to the current change set to comprehend that. Later on in the review when I reach the definition of saveFileToS3() if it does anything sneaky, doesn’t do anything necessary to that logical operation (like maybe the file is initially marked private and a second call is needed to mark the file as accessible) then I’ll flag that. Code factorization is a tool for clarity and you should rely on and reinforce it - and if you are trusting ot you should verify that.

It sorta sounds like your company may be drastically underinvesting in code maintenance (everyone under invests but there is a reasonable amount of investment to demand) though, that’s a red flag for me and may mean it’ll be difficult for you to function in that environment.

@[email protected]
creator
link
fedilink
English
22d

I agree that maintainability is important but the issue is that the team lacks that level of (professional) maturity. Actually they used to avoid writing design documents until I joined the organization and made everyone start doing it. They would simply see the user story and then get to work on the code. We’re talking about code written back in 2018 by some contractors, getting patched till today until it’s now spaghetti with meatballs and ragu on top.

I am planning a training session on DDD and clean architecture for the team so hopefully they will improve later.

@[email protected]
link
fedilink
English
12d

Damn, you sound like me at my company… except I just got fired because I can’t fix code fast enough, and they reject any effort to improve it. 35 years of experience here. In some environments, pointing out problems leads to unemployment.

@[email protected]
link
fedilink
English
12d

Someone needs to be the advocate for clean code and how it will reduce incidents and errors - it’s not easy but you can make progress. If you’re that deep in the whole automated tests might be a good focus?

@[email protected]
link
fedilink
English
22d

I’m a fairly early career dev, my job doesn’t really give me a lot of opportunity to write new code, instead I spend most of my time updating other people’s code, much of which is a legacy rat’s nest. Most of my time on a given story is spent trying to understand the code I’m given, and as I’m reading it I often feel like my eyes start drifting apart, it’s really hard to focus on it and understand the meaning.

The two most helpful things I’ve found are a) diagramming everything out. For that I have a big white board next to my desk, like 15 scattered notebooks and a tablet for onenote. b) my medication.

I was put on Ritalin about a year and a half ago, and (when I remember to take it) the difference is night and day. I wouldn’t say the medication makes the work easier, but it does make me feel motivated to do it and be less distracted even though it’s not work I necessarily want to be doing.

I do feel I should mention since you mentioned having some anxiety issues on other medication that I can end up with the save issue, but I’ve noticed that it only happens if I didn’t eat before taking it, or take it too late in the day to where it’s still fully in effect after I’m done working.

I also absolutely feel you on wanting to refactor everything that doesn’t make sense - it would make life so much easier, but I’m not allowed to do it -_-.

Create a post

A casual community for people with ADHD

Values:

Acceptance, Openness, Understanding, Equality, Reciprocity.

Rules:

  • No abusive, derogatory, or offensive post/comments.
  • No porn, gore, spam, or advertisements allowed.
  • Do not request for donations.
  • Do not link to other social media or paywalled content.
  • Do not gatekeep or diagnose.
  • Mark NSFW content accordingly.
  • No racism, homophobia, sexism, ableism, or ageism.
  • Respectful venting, including dealing with oppressive neurotypical culture, is okay.
  • Discussing other neurological problems like autism, anxiety, ptsd, and brain injury are allowed.
  • Discussions regarding medication are allowed as long as you are describing your own situation and not telling others what to do (only qualified medical practitioners can prescribe medication).

Encouraged:

  • Funny memes.
  • Welcoming and accepting attitudes.
  • Questions on confusing situations.
  • Seeking and sharing support.
  • Engagement in our values.

Relevant Lemmy communities:

Autism

ADHD Memes

Bipolar Disorder

Therapy

Mental Health

Neurodivergent Life Hacks

lemmy.world/c/adhd will happily promote other ND communities as long as said communities demonstrate that they share our values.

  • 1 user online
  • 49 users / day
  • 168 users / week
  • 211 users / month
  • 394 users / 6 months
  • 1 subscriber
  • 551 Posts
  • 8.36K Comments
  • Modlog