


From software legacy to strategic opportunity: The starting point (I)
Jan 15, 2025 am 06:14 AMRefactoring legacy software: from challenges to opportunities
This article tells how we handle the internationalization of an logistics management system (OMS) and the challenges of integrating with new e-commerce platforms. The system was developed in 2018 to optimize the order preparation process of a booming e-commerce company and efficiently integrate with different logistics operators. Built using PHP (Symfony), MySQL, Socket.io, and jQuery, it covers the entire process from packaging to shipping, including features such as order tracking, courier connections, label generation, and order preparation performance metrics.
The accumulation of technical debt
This system worked well for many years, but as the business grew, its limitations became increasingly apparent. Technical debt is particularly worrisome, affecting multiple levels of a project. In terms of technical infrastructure, the application runs on outdated frameworks and base language versions:
- Symfony version (4.0) is not a long-term support (LTS) version and will stop receiving security updates starting from January 2019.
- PHP 7.1 has also ended its life cycle and the system lacks critical security updates.
In addition to outdated versions, the project also has serious flaws in the fundamentals of software development:
- Lack or Insufficient Testing: A lack of automated testing (unit, integration, and end-to-end testing) not only hinders the early detection of bugs, but also makes any modifications potentially jeopardizing the stability of the system.
- Lack of coding standards: The codebase does not follow any documented patterns or standards, and even if there are, they are not consistent with industry best practices. This makes both maintenance and onboarding new developers to the project difficult.
- Inadequate documentation: Existing documentation is sparse and often incomplete. This affects not only technical development but also the understanding of the business processes implemented in the code.
- Incomplete version control: Git history lacks explanation, commit granularity is rough, messages do not follow any conventions, and lack background information on the changes made. This makes it difficult to understand the evolution of code and decisions made over time.
The accumulation of technical debt not only poses a threat to the stability and security of the system, but also:
- Reduced the development speed of new features
- Increased risk of introducing bugs
- Increased the difficulty for new members to join the team
- Increased maintenance costs
- Complicates problem diagnosis and resolution
Structural limitations
The original architecture had coupling issues that seriously affected its flexibility and scalability:
- Completely dependent on the main e-commerce platform: The application cannot run independently, and all logistics operations are directly dependent on the data and processes of the e-commerce platform. This means that any changes to the main platform may break the functionality of the system.
- Shared database causing performance issues: Logistics applications and e-commerce platforms use the same database, which leads to performance issues, especially during peak load periods for either application. Additionally, this configuration complicates permission management because any access to the database may compromise important data from other systems.
- Cannot run standalone: This app is designed to run only with e-commerce platforms. Not only does this limit its portability, it also prevents testing in an isolated environment or migrating to other platforms. Its dependencies are not properly encapsulated, any attempt at isolation would require large and costly changes to the entire system, and the Single Responsibility Principle (SRP) is not adhered to in the main class.
- Difficulty in implementing new features: Lack of compliance with the Open/Closed Principle (OCP) and Liskov Substitution Principle (LSP) greatly hinders the evolution of the system. New features require modifications to existing code, increasing the risk of introducing regressions. Additionally, direct dependencies between modules make following the Dependency Inversion Principle (DIP) nearly impossible.
These structural limitations not only reduce the maintainability and scalability of the system, but also increase the risks associated with any modification or evolution, leaving the application in a technically fragile and strategically vulnerable state.
Development management and strategic alignment
One of the most significant challenges is not only technical, but also strategic. While external development is functionally correct, there are significant organizational limitations:
- Disconnected from global strategy: Development is done in silos without a complete understanding of the company’s internal goals and processes. This results in features that, although technically correct, don't always meet the actual needs of the business.
- Lack of strategic prioritization: Implementation of new features lacks a clear evaluation and prioritization process. There is no questioning whether a feature is truly necessary, whether it is the best way to implement it, or whether a more efficient alternative exists.
- Reactive Development vs. Proactive Development: Development primarily follows a reactive model, addressing immediate needs without considering long-term impacts or potential synergies with other processes in the company.
- Lack of Validation Process: The lack of a structured review and validation process results in features that, while working, don’t always provide the best solution for the end user or the company’s overall goals.
This situation is unsustainable in the long term because it:
- Resulting in products increasingly deviating from actual needs
- Hinders integration with other company systems and processes
- Complicates strategic decisions about products
- Limits the team’s ability to innovate and continuously improve
Impact of basic costs
An often overlooked but particularly important aspect in this project is base cost, which I believe is a key concept in software development and refers to the cost of keeping a system running even without adding new features or making improvements. minimum cost required.
In our case, base costs include all costs associated with maintaining obsolete framework and language versions, resolving emergencies due to accumulation of technical debt, managing dependencies with other systems, adapting to coupled architectures, and domain knowledge costs incurred due to insufficient understanding. All of this consumes a significant amount of available resources and directly impacts the ability to invest in innovation and continuous improvement.
Although this factor was not the decisive factor in our decision to internalize development, it was quite influential in the initial diagnosis of the project. Base costs are often ignored when assessing the sustainability of a system, but in this case it clearly demonstrates that current strategies are unsustainable in the long term. Furthermore, as we will see in subsequent articles, any attempt to maintain the existing structure will exponentially increase the base cost over time.
For a more detailed explanation of basic cost concepts and their importance, it is recommended to refer to Eduardo Ferro’s original article.
Turning Point: New Challenges and Strategic Decisions
In any refactoring project, there are multiple strategies that can be employed, and the dilemma is often encountered: strangler fig or big bang rewrite.
The initial technical decision was to work within the same legacy project using the Strangler Pattern, an approach that involves developing a new module or system that gradually replaces parts of the old system. This strategy allows us to make parallel changes, reduce risk, and maintain current functionality while building a stronger foundation to support future functionality.
However, from a business perspective, this option poses an undue risk to the existing system (which is already operational and performing its functions). We decided to avoid touching the existing project and instead develop a standalone application to meet the new needs.
This shift resulted in us forking the existing codebase, a decision that was technically feasible but had certain drawbacks:
- Duplication of code bases: Two separate code bases now need to be maintained.
- Database Separation: Data structures must be copied and adapted for each system.
- Infrastructure replication: Requires deploying independent servers and ensuring appropriate observability for each system.
- Increased cognitive load on the team: All this duplication requires extra effort to maintain consistency between the two systems, thereby increasing the team’s complexity and risk of errors.
This approach allows us to move towards independent solutions, ensuring the stability of existing systems while developing a project aligned with new strategic goals. However, a detailed analysis of the pros and cons is necessary to plan and address this challenge with confidence. In addition, we reached a consensus with the business level not to expand functionality and to tightly control the project's backlog until the migration to the new e-commerce platform was completed.
優(yōu)點 | 缺點 |
---|---|
在非生產環(huán)境中工作,降低生產環(huán)境的風險 | 需要暫時維護多個項目 |
自由地從零開始實施新技術和模式 | 在維護方面的努力暫時重復 |
不必擔心舊系統(tǒng)的技術限制或依賴關系 | 由于需要在系統(tǒng)之間同步更改,功能的重復可能會長期減緩開發(fā)速度 |
能夠專注于必要的特性 | 截止日期的風險,因為有兩個代碼庫 |
有機會從一開始就實施最佳實踐 | 項目管理的復雜性 |
更容易從一開始就實施測試 | 需要與歷史數(shù)據保持兼容性 |
靈活地適應新的業(yè)務需求 | 初始時間和資源成本更高 |
更好地與公司的整體戰(zhàn)略相一致 | 可能暫時丟失非必要的特性 |
Conclusion and next steps
The decision to internalize and rewrite legacy software is never easy, especially when the software is capable of doing its job. The saying "If it works, don't touch it" will always be there. However, sometimes it takes one step back to take two steps forward.
In subsequent articles in this series, we will explore how we responded to these challenges, the technical and strategic decisions we made, and how we turned these challenges into opportunities for improvement and team development.
The above is the detailed content of From software legacy to strategic opportunity: The starting point (I). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ToversionaPHP-basedAPIeffectively,useURL-basedversioningforclarityandeaseofrouting,separateversionedcodetoavoidconflicts,deprecateoldversionswithclearcommunication,andconsidercustomheadersonlywhennecessary.StartbyplacingtheversionintheURL(e.g.,/api/v

TosecurelyhandleauthenticationandauthorizationinPHP,followthesesteps:1.Alwayshashpasswordswithpassword_hash()andverifyusingpassword_verify(),usepreparedstatementstopreventSQLinjection,andstoreuserdatain$_SESSIONafterlogin.2.Implementrole-basedaccessc

PHPdoesnothaveabuilt-inWeakMapbutoffersWeakReferenceforsimilarfunctionality.1.WeakReferenceallowsholdingreferenceswithoutpreventinggarbagecollection.2.Itisusefulforcaching,eventlisteners,andmetadatawithoutaffectingobjectlifecycles.3.YoucansimulateaWe

Proceduralandobject-orientedprogramming(OOP)inPHPdiffersignificantlyinstructure,reusability,anddatahandling.1.Proceduralprogrammingusesfunctionsorganizedsequentially,suitableforsmallscripts.2.OOPorganizescodeintoclassesandobjects,modelingreal-worlden

To safely handle file uploads in PHP, the core is to verify file types, rename files, and restrict permissions. 1. Use finfo_file() to check the real MIME type, and only specific types such as image/jpeg are allowed; 2. Use uniqid() to generate random file names and store them in non-Web root directory; 3. Limit file size through php.ini and HTML forms, and set directory permissions to 0755; 4. Use ClamAV to scan malware to enhance security. These steps effectively prevent security vulnerabilities and ensure that the file upload process is safe and reliable.

Yes, PHP can interact with NoSQL databases like MongoDB and Redis through specific extensions or libraries. First, use the MongoDBPHP driver (installed through PECL or Composer) to create client instances and operate databases and collections, supporting insertion, query, aggregation and other operations; second, use the Predis library or phpredis extension to connect to Redis, perform key-value settings and acquisitions, and recommend phpredis for high-performance scenarios, while Predis is convenient for rapid deployment; both are suitable for production environments and are well-documented.

In PHP, the main difference between == and == is the strictness of type checking. ==Type conversion will be performed before comparison, for example, 5=="5" returns true, and ===Request that the value and type are the same before true will be returned, for example, 5==="5" returns false. In usage scenarios, === is more secure and should be used first, and == is only used when type conversion is required.

The methods of using basic mathematical operations in PHP are as follows: 1. Addition signs support integers and floating-point numbers, and can also be used for variables. String numbers will be automatically converted but not recommended to dependencies; 2. Subtraction signs use - signs, variables are the same, and type conversion is also applicable; 3. Multiplication signs use * signs, which are suitable for numbers and similar strings; 4. Division uses / signs, which need to avoid dividing by zero, and note that the result may be floating-point numbers; 5. Taking the modulus signs can be used to judge odd and even numbers, and when processing negative numbers, the remainder signs are consistent with the dividend. The key to using these operators correctly is to ensure that the data types are clear and the boundary situation is handled well.
