How to find unused code in a legacy system before you migrate it

Why migrating dead code wastes budget

Every line of code you carry into a new platform has a cost. Someone has to read it, convert it, test it and maintain it afterward. If a chunk of that code never runs, or runs only for a workflow the business abandoned years ago, you pay for all of that and get nothing back.

Legacy systems are especially prone to this. Decades of business logic pile up in COBOL, Oracle Forms, PL/I and aging Java codebases. The original authors are often gone, the documentation is incomplete, and nobody wants to be the person who deletes something that turns out to matter. So the safe-looking choice is to migrate everything. That choice quietly inflates scope, stretches timelines and carries obsolete behavior into the new architecture.

The better approach is to find out what is actually in use before you commit to a scope. That takes two kinds of evidence, runtime usage and dependency relationships, and one final check with the people who own the business process.

Start with runtime usage

The most direct sign that code is unused is that it never executes. Look for production evidence over a long enough window to cover the full business cycle, including month-end, quarter-end and year-end jobs, which are exactly the programs that look dead for eleven months of the year.

  • Execution logs and job schedulers. Check which batch programs, transactions and reports were actually invoked, and which scheduled jobs exist but produce output nobody reads.
  • Screen and form access. In an Oracle Forms application, find the forms and menu entries that no user has opened in your observation window.
  • Table and file activity. Data that is never read, or that is written but never consumed downstream, usually points to a retired workflow.

Runtime data tells you what was used. It cannot tell you why something was not used, and it cannot prove a rarely triggered path is safe to remove. Treat it as a strong signal, not a verdict.

Use dependency maps to confirm what is truly inactive

A program that nobody calls directly may still be called by something else. A field that looks unused on screen may feed a calculation, a ledger entry or an audit record. This is why runtime evidence alone is risky, and why a map of dependencies matters.

A dependency map shows how components relate: which programs call which, which fields flow into which rules, and which tables are touched by which workflows. With it you can separate three cases that look identical from the outside:

  • Code with no callers and no runtime activity, which is a strong candidate to retire.
  • Code with no direct activity but live dependents, which must be kept or deliberately rewired.
  • Code that is reachable only through a rare condition, which needs a business answer before anyone decides.

Building this map by hand means reading a lot of code. Replai reads source code, metadata and dependencies across COBOL, Oracle Forms, PL/I and other stacks and builds a structured view of the rules, workflows and relationships, with each finding linked back to its source. That lets a team trace what a change would touch before deciding something is dead. If you want the technique behind this, see our guides on data lineage in legacy systems and change impact analysis for legacy code.

Confirm with business owners before retiring anything

Technical evidence narrows the list. It does not close it. Before anything is removed from scope, put each candidate in front of the person who owns the process it supports.

Keep the conversation concrete. Instead of asking whether a program is still needed, show what you found: the workflow it belongs to, the last time it ran, what depends on it, and what would stop happening if it disappeared. Owners can often confirm in minutes that a process was replaced years ago, or point out that a quiet annual job is required for a regulatory filing.

  1. List each candidate with its runtime history and dependencies.
  2. Ask the process owner to confirm retire, keep, or investigate.
  3. Record the decision and the person who made it, so the rationale survives the project.
  4. Retire in stages where you can, and keep the original source available until the new system has run through a full business cycle.

That record matters later too. Regulators and auditors may ask why a rule exists in one system and not the other. Our guide on auditing business logic changes for regulatory reviews covers how to keep that evidence visible.

Fold the findings into your migration plan

Once candidates are confirmed, the results change the shape of the project. Scope shrinks, estimates get tighter, and the team knows which business rules they must preserve rather than guessing. Understanding the system first is also what keeps surprises from showing up halfway through delivery.

If you are still deciding how to approach the migration itself, the legacy code analysis guide explains how to understand a codebase you did not write, and the modernization cost guide shows how scope feeds into budget. For Oracle Forms estates specifically, start with how to plan the move to Oracle APEX.

Frequently asked questions

Why shouldn't I just migrate all of my legacy code?

Every line you migrate has to be converted, tested and maintained. Code that never runs adds scope, cost and obsolete behavior to the new system without delivering any value.

How do I tell whether legacy code is actually unused?

Combine runtime evidence, such as execution logs, scheduler history and screen or form access, with a dependency map that shows what calls the code and what data it feeds. Code with no activity and no dependents is the strongest candidate to retire.

Why isn't runtime usage data enough on its own?

It only shows what ran during your observation window. Month-end, quarter-end or year-end programs can look dead for most of the year, and code with no direct callers may still feed a calculation or an audit record.

Who should approve retiring a legacy workflow?

The business owner of the process it supports. Show them the workflow, its last execution, what depends on it and what would stop happening, then record their decision for future audits.

Can Replai help find unused components?

Replai reads source code, metadata and dependencies across COBOL, Oracle Forms, PL/I and other stacks and builds a map of rules, workflows and relationships linked to their source. Teams can use that map to trace what a component touches before deciding it is inactive.

Should I delete the original code once a workflow is retired?

Keep the original source available until the new system has run through a full business cycle. Retiring in stages where possible gives you a way back if something turns out to matter.