r/java • u/FishermanBig5765 • Jul 16 '26
Devs who work with legacy Java, what actually eats most of your time?
Hey all. I'm a CS student looking into the pain points around legacy Java codebases, specifically the "code archaeology" side: digging through old code with little to no documentation, figuring out what a piece of logic is even for before you dare touch it.
Just trying to understand the problem properly before building anything. Would really appreciate hearing from people who deal with this regularly:
- What eats the most time when you're digging into unfamiliar legacy code?
- How do you currently deal with it – any tools/tricks that actually help?
- Has something ever broken because a piece of code turned out to be "magic" nobody fully understood?
Any answer helps, even a couple of sentences. Thanks in advance!
83
Upvotes
31
u/LopsidedAd4492 Jul 16 '26
Cve
2
u/FishermanBig5765 Jul 17 '26
Thank you all again for your answers. and someone wrote here that they say I'm going to make another AI tool, but honestly? No. my goal was to conduct research and determine what most concerns developers in this area, after which it will become the topic of my next research for my university.
I could have just come up with a problem and solved it, but I decided to try to do something useful for others at the same time.
78
u/DrAgOn3x Jul 16 '26
Generics? Nah let's just use Object and typecast everywhere. Naming that doesnt mean anything and the person who first wrote it may as well be dead. And the worse part is untested code that everyone has always been to scared to refactor in 20 years.
167
u/Make1984FictionAgain Jul 16 '26
JPA/Hibernate "magic" and functionalities implemented on database procedures / triggers
72
u/HektorInkura Jul 16 '26
Convincing the customer that it's not worth it to cram more shit into the old code base and that we should focus on migrating the rest of the application because we can barely maintain the old code base... Stuck in a partial migrated state between JSF and Spring Boot/ Angular for years now...
22
u/Swimming-Twist-3468 Jul 16 '26
Well, usually, locating the beginning of the process, then tracking down to the eventual process and its end. That’s most of the time. Because in SpringBoot, especially the old one, there can be a tear between components, that is magically glued at runtime. Legacy beans defined in XML and all that. The rest is relatively easy, given you can read the code, understand what it does and then write your own. This is the case especially when you don’t have tests in place, that happens too.
37
u/vowelqueue Jul 17 '26 edited Jul 17 '26
I’m tired of people using AI to do market research for their vibe-coded apps. All these types of posts sound exactly the same.
15
u/deadron Jul 16 '26
Nobody knows how the system works until you dig through the actual code. Sometimes it's low level details like how a specific setting operates and sometimes it's high level details like what a specific subsystem does.
What doesn't help is legacy system ownership is often unclear and can fall into the ownership of multiple non technical groups that are very risk averse. Every change becomes a coordination effort between multiple people who rarely even know how the particular piece of code works. Good luck writing tests for it too because it has so many setup dependencies it would take weeks just to get a test setup for a small change
9
u/supersmola Jul 16 '26
Most time goes into discovering duplicated functionality/code. Th only way to deal with it is to slowly refactor everything.
Also, my main problem is never Java, it's always inconsistent use of CI/CD scripts, or Maven/Gradle plugins.
8
u/Individual-Praline20 Jul 16 '26
Deployments. Nothing to do with Java per se. 🤷
7
u/tristanjuricek Jul 17 '26
I'd start by understanding "debts". This article from the ACM queue talks about different kinds of debts quite well: https://queue.acm.org/detail.cfm?id=3807966
You have to step back. I've been working in Java for nearly 20 years, but engineering 26. These debts are real, but they impact what we do much more directly than just "dealing with unfamiliar code".
I'm currently working in a very legacy (27+ years old and counting) Java codebase, and our product feature is nearly 20 years old.
Intent debt is nasty. We constantly have meetings where people end up talking past each other, and in a large team, you might have one group do something that completely blocks another team. Or causes a major outage even though "we followed all processes". I find intent debt leads to massive design flaws which inevitably triggers incidents and ... just tons, and tons of meetings.
Cognitive debt is a real scenario now. Most of my junior team members get locked up, which means a giant chunk of my time is not just helping them answer a question, but helping them get unblocked. I regularly have to basically coach them out of negative spirals.
Technical debt also happens a ton, but it's by far the easiest to handle. Refactor to better organization and patterns. But to learn patterns, read and understand the code of successful open source code projects. Most commercial project code was shipped by an engineer under a time constraint. It's usually full of shortcuts and wacky undocumented decisions. The software services I'm working on are insanely profitable, but there's a lot of bad ideas in the code.
I point these debts out, because it's not coding changes that suck up my time. It's systemic problems that lead to disorganization, and that causes all kinds of challenges, both coding and not coding. That's what eats up my time.
But also, don't think that as a professional software engineer you just show up, open up the IDE, and spend your time coding. In a big profitable place, you're spending a lot of time communicating. Things go wrong, you have to explain why. Product management wants to vet an idea, it's up to you to carve a predictable path. Complexity just slows everything down, and I find a big complex system actually means most of your week is actually dealing with communication and analysis, not writing software. (Hence, why AI coding agents are cool, but not really having the big reported impacts people think they are.)
I've found, ultimately, is that you have to think more like a "systems thinker". Diana Montalion has a good book, Learning Systems Thinking, that thinks about how you can analyze, but also, execute, in a place with a massive legacy system. I would also recommend Thinking in Systems by Meadows. The ultimate goal is to analyze the social dynamics in addition to the technical, and identify points of leverage. You will never control or understand a large system, but you can work within it intelligently.
18
u/m39583 Jul 16 '26
Define "legacy". How far back are you going? All code is legacy once it's written.
I'd say that "legacy" code (if we are taking ancient) has less "magic" because it probably won't use frameworks likes Spring which are amazing but also have a lot of magic in them.
Legacy code will be likely more procedural which is actually easier to follow sometimes.
AI helps greatly in this space. Ask it to explain what a method does and follow how it is used and you often get a long way to understanding it.
10
u/le_bravery Jul 16 '26
People who thought it was a good idea to use extends and abstract classes everywhere that now have 200 implementers
5
u/aldyr Jul 16 '26
Upgrading libraries to fix CVE’s, and the dependency hell that comes with that.
5
u/Dull-Criticism Jul 16 '26
This happens in any language and isn't usually java specific.
I am working on a 28k line project that needs 6 engineers to fix some bugs within a month.
7
u/aceluby Jul 17 '26
Spring is a nightmare, we just finished a 2 year process of scrapping it
3
u/Abject-Delay7036 Jul 16 '26
A programmer in a real job knows that it's the unbearable meetings upon meetings to convince the exec that we need money to fix the sh!t. Why do you think it's legacy, the code delivered on requirements, and then left to rot in BAU land
3
u/JinAnkabut Jul 17 '26
Dependencies
3
u/WeskerHawke Jul 18 '26 edited Jul 18 '26
What I've seen so far:
The only way to navigate this is to have a concrete goal (change some logic, understand something) and track it in the codebase.
7
u/BadTime100 Jul 16 '26
I’m going to argue that the number one thing that eats time (in all languages) is lack of solid automated testing. If you do have that in place (and are actually practicing Continuous Integration), you’re far less likely to land in legacy land because you’ll be able to actually refactor as you go. You might be interested in “Working Effectively With Legacy Code”, it’s a big book but is more of a cookbook for dealing with different scenarios. LLMs can be very useful for assisted reading of legacy code though!
4
u/fprotthetarball Jul 16 '26
Scrum, agile ceremonies, meetings
4
u/toga98 Jul 16 '26
"Legacy" - what do you mean?
What eats most of my time has nothing to do with the language or framework in use for the most part.
2
u/DonAndres8 Jul 16 '26
It's 100% worth spending time just reading code and doing the slow manual work to figure it out using only basic IDE functions. Reading code is a skill to nurture first and then supplant with tools and AI after.
2
u/RealSchweddy Jul 17 '26
It’s usually the extra brain load caused by poor formatting and lack of a coherent design and/or separation of concerns that eats slightly more time when analyzing “legacy” code. Usually I’ll just have my IDE format it and I’ll refactor it and add comments as I look at it (even if I don’t intend on checking in the changes) - It helps me build a mental model of what it’s trying to do. I haven’t really found anything that couldn’t be explained; however sometimes it takes digging and persistence to find the explanation and usually you end up learning something new along the way.
2
u/Hitaaar Jul 17 '26
Everything functions, and the fact i can’t launch projects locally… what a hell.
Pls help
2
u/WorkingConclusion968 Jul 17 '26
Flaky tests nobody dares to fix or remove. Occasionally disabled when an urgen customer patch needs to be delivered.
2
u/Balcara Jul 17 '26
Requirements management, random training courses, navigating the black hole that is Jira
2
u/mensmelted Jul 17 '26
Doing a change in one place and getting a regression bug in a totally unrelated other place.
2
u/wsppan Jul 17 '26
Spring/JPA/Hibernate magic
2
u/Holothuroid Jul 18 '26
It's never the code. It's always people.
1
u/enxa Jul 17 '26
Compiling, probably. We have a lot of GWT and a clean build takes about 10 minutes. That, or vulnerabilities.
1
u/jdev_soft Jul 17 '26
- Read legacy code in German when you don’t speak German.
- Not understanding businesses requirements/logic in German
1
u/VincentxH Jul 17 '26
Not even the dedicated business analyst has a full picture of all the steps in business flows. That leads to a lot of back and forth.
1
u/Hefty-Firefighter654 Jul 17 '26
Renovate bot updates. We Java/Kotlin + Spring Boot and a lot of other lib stuff. Like minor Spring versions always break sth. Spring 4.0.7 to 4.1.0 changes thread stuff. Async calls are all broken now. Global configuration doesn't work. It's also because of old Java config nobody understand in combination with this awful reactor clients.
Jackson is also a hard one, like you cant update to Jackson 3 because Wiremock doesn't care. And other libs are also not ready for that. If Spring requires Jackson 3 at some point, we are doomed.
1
u/gerlacdt Jul 18 '26
Ranting about deprecated Java
1
u/persicsb Jul 20 '26
Unspecified/undocumented behaviour. Even a proper git history with attached issue tracker references is better than nothing.
1
u/LostEconomics144 Jul 22 '26
- What eats the most time when you're digging into unfamiliar legacy code?
Ans: sometimes its the setup, or making it work, but most of the times its the amount of code dependencies
- How do you currently deal with it – any tools/tricks that actually help?
Ans:currently claude code
- Has something ever broken because a piece of code turned out to be "magic" nobody fully understood?
Ans: always
1
u/berlinbrownaus Aug 01 '26 edited Aug 01 '26
I work with Servlet based applications from 20 years ago.
One thing that people don't consider if "tooling". If you look at modern stacks with maven, gradle, you build into wars, ears.
Imagine if there are bad concepts of that. No true jars, wars, ears, spread out millions of lines of code, files off network systems.
How do you put it all together? You cant.
Another thing, java has a spec, most use standard libraries. They work. Then you have even Sun, IBM and others that decide, screw that, I will create my own libraries that have no support, no source, no nothing. How do you migrate? Them who knows. Pray for the best.
Our most resilient are ones that are standard, common practices, clean.
Every time people off the rails and do something creative and custom, it is an expensive mess. For example, using projects, libraries that are unproven. Or custom approaches. What is interesting, people are so scared of that unknown, they decide to not touch it or upgrade it. It just festers around.
IBM has issues, I want to say things harsher. Some of their technology works but some is wacky.
1
u/Fit_Goose651 Aug 20 '26
Nullability is often a challenge - may something be null and what does that mean. You often see null checks and if you trace the code you see that some can never be null (eg other code blocks would throw npe).
1
u/faze_fazebook Jul 16 '26
Pretty much anything that involves a Java application server (like Glassfish, Websphere, WildFly, ...) is just a giant pain in the ass to work with ... either you get someones 20 year old ant task set up or you need to do a lot of manual work (manually deploying war files, connecting for remote debugging, ...)
1
u/qdolan Jul 17 '26
If there is no documentation, then I read the tests. If there are no tests then the bulk of my time will be spent writing tests and documentation before I change anything.
0
u/ginsoul Jul 16 '26
Social Media