页面简介
Learn how to assess a legacy application, choose a bounded modernization step, and reuse the method with a GitHub Copilot agent skill.
正文摘录
How to choose the next safe step in application modernizationLearn how to assess a legacy application, choose a bounded modernization step, and reuse the method with a GitHub Copilot agent skill.Build evidence before choosing a targetA request to modernize an application often starts with a technology question: Which framework should replace the old one? Before you choose, find out what still works. Then collect evidence that can act as a regression net for that behavior and show where modernization is necessary. I used an evidence-first method on four public applications, from a small Node.js game to a large Java enterprise resource planning (ERP) application. Each needed a different treatment, but the way I collected evidence, chose the next experiment, and decided on possible proof points was repeatable. This post walks through that process so you can apply it to one application of your own. It also shows how to encode the procedure in a GitHub Copilot agent skill while keeping architectural judgment with the people responsible for the system. Build evidence before choosing a target The label on an application rarely tells you enough. “Java microservices” doesn’t tell you which Java Development Kit (JDK) runs in production, where that version is pinned, whether the tests execute, or which interfaces other systems depend on. “Legacy monolith” doesn’t tell you whether the business core is broken or whether one retired platform dependency prevents the application from starting. Before you recommend a change, build a small evidence inventory: Manifests, lockfiles, entry points, and deployable components Verified commands for installing, building, testing, packaging, and running Runtime pins in containers, CI workflows, deployment files, and developer tooling External contracts such as APIs, database behavior, file formats, and user workflows End-of-life frameworks and dependencies, with evidence that the application still uses them Record uncertainty while you work. I use three simple labels: documented, inferred, and unverified. If two files disagree about the Java version, resolve the contradiction. If you can’t determine whether a CI check blocks merges, say so. Record the unknown rather than treating a guess as a finding. That inventory gives you something concrete to review with the people who own the application before you propose changes. Choose the least disruptive treatment that works Once you understand the application, make the decision per component. A single system can contain code that should stay, dependencies that should be swapped, and one subsystem that genuinely needs a rewrite. First, check whether a capability is still needed. Remove it only after verifying that it is unused or superseded and confirming that decision with its owner. Removal is a separate decision, and it’s not necessarily the most disruptive one. For a capability you still need, start with the option that changes the least: Keep it. Supported code that still fits the job doesn’t need a modernization story. Upgrade it. Move to a supported major version and fix the breaking changes. Swap it. Replace an abandoned dependency while preserving the existing design. Wrap it. Stabilize a useful interface and replace the internals in increments. Rewrite it. Use this when no responsible upgrade path exists or the architecture cannot meet the requirement. This is a decision order, not a universal ranking of effort or risk. Ask what evidence justifies choosing a more disruptive option. “The code is old” is not enough. A known vulnerability with no patched release for the pinned version, a dependency that fails on the required runtime, or a measured reliability target the current design cannot meet can justify escalation. Decide what proof is possible The next question is whether the component can run well enough to produce evidence, even if the legacy CI pipeline is not green. Run a time-boxed feasibility check. Try to install dependencies, build on an available toolchain, start the component, and execute at least one meaningful test. Stop when the time box expires. The result sends you down one of two paths. Capture behavior, then upgrade. Use this path when the old application can still run at an acceptable cost. Record its externally visible behavior, fix the test harness where practical, and use those checks to verify the upgrade. Build a small modern slice first. Use this path when the old component cannot run until you have already changed it. Move the thinnest useful workflow to supported technology, prove it, and expand from there. Requiring a complete legacy test suite in this situation is circular. Restoring the test suite is part of the modernization. I use the following safety levels, adapted from the doc-and-modernize skill, to describe the strongest regression protection available: LevelStrongest honest protectionL0No usable regression net; treat the old code and available documentation as the specification.L1Small reversible changes, old and new paths in parallel, smoke checks, and domain review.L2Captured inputs and outputs, snapshots, or other behavioral comparisons.L3Automated checks cover part of the system, with the remaining gaps named.L4An automated CI gate combines lint, unit, behavioral, and end-to-end checks for the agreed scope. State what you can prove and what risk remains. Even an L4 gate cannot establish that every possible behavior is correct. APIs, database effects, files, rendered output, and business workflows often make durable comparison points because those behaviors can survive a framework or language change. PiggyMetrics: capture behavior, then upgrade PiggyMetrics was the clearest example of an application that looked worse than it was. The project used Java 8, Spring Boot 2.0.3, Spring Cloud Finchley, Zuul, Hystrix, and the old spring-security-oauth2 library. It would have been easy to call the application unworkable and start drawing a new architecture. The feasibility check told a different story. The recorded feasibility results show these two probes against the legacy checkout with JDK 8: CommandRecorded resultWhat it establishedmvn -pl config -am compileExit code 0The selected config module and required reactor dependencies compiled.mvn -pl account-service -am test14 tests ran: five passed and nine erroredSome service logic passed; embedded MongoDB initialization blocked the other tests. These are historical results, not commands expected to reproduce those failures on the modernized checkout. The nine errors traced through Failed to load ApplicationContext to an embedded MongoDB download returning HTTP 403. The pinned binary also targeted i386, which would not run on the Apple Silicon host. The probes did not establish that the whole application ran or that its integration behavior was correct. They did give me a narrower next step: replace the test dependency and rerun the affected tests before changing the production stack. That result saved me from making a very tidy, very expensive mistake. I had already started thinking about which parts of the architecture I might replace. One broken test dependency did not justify redesigning the application, and five passing tests established behavior I could check for unintended changes during modernization. The modernization plan turned that evidence into a capture-then-upgrade sequence: Replace the embedded database dependency with Testcontainers and establish a green baseline on the existing stack. Put that baseline in GitHub Actions before changing the production runtime. Move from Java 8 to Java 21 and Spring Boot 3.3. Replace obsolete components behind their existing interfaces: Zuul with Spring Cloud Gateway, Hystrix with Resilience4j, and the retired OAuth stack with Spring Authorization Server and JSON Web Token (JWT) resource servers. Carry the baseline forward and add contract checks around the parts whose behavior changed. The first acceptance gate was a passing baseline on the old stack, not merely the successful installation of a replacement dependency. Running checks in CI and enforcing them as merge requirements were also separate steps in the plan. The result summary records the Java and Spring upgrades while retaining the microservice decomposition that the application exists to demonstrate. Eureka and Cloud Config stayed; the two monitoring modules used by the retired Hystrix and Turbine stack were removed. The in-scope build went from nine modules to seven. Those versions describe the experiment, not a recommendation to select the same versions today. Choose targets against your current support requirements. The useful lesson is how the repository evidence narrowed the change. The method changes with the system The same process produced different answers on two smaller applications. Their pinned reports describe these choices: ApplicationWhat stayedWhat changedStrategyBrowserQuestCanvas renderer, pathfinding, world model, protocol, and game-loop modelNode 0.4.7 to Node 22, two obsolete WebSocket stacks to ws, plus tests and GitHub ActionsUpgrade and swapDOOMRenderer, 35 Hz simulation model, and WAD game-data formatX11 video and OSS audio replaced with SDL2; platform code adapted for modern 64-bit systemsPreserve the core and replace the platform The comparison needs one important qualification: DOOM’s checks froze outputs from the modernized engine itself. They protected against later regressions; they did not independently prove parity with a period-correct legacy binary. Naming that limit is part of choosing an honest safety level. Scaling the method without pretending the product is finished I then applied the method to ADempiere, a large Java suite covering ERP, customer relationship management, manufacturing, supply chain, accounting, and point of sale. The scale changed the controls, but not the method. The work established a reproducible build, moved the runtime to JDK 21, preserved SOAP web-service contracts while repla