Software Design and DevelopmentUnit 914 min read
Software Maintenance & Evolution: Types, Challenges & Strategies
Unit 9 of Software Design and Development explores the lifecycle beyond deployment—how software is updated, repaired, adapted, and optimized over time. Learn corrective, adaptive, perfective, and preventive maintenance, cost models (e.g., Lehman’s Laws), reverse engineering, reengineering, and tools like version contro
Why Maintenance? The Hidden 70% of Software Costs
Software doesn’t just “work and forget.” Studies show 70–80% of a system’s lifetime costs come after deployment. Why?
- Bugs slip through (even in Agile/DevOps).
- User needs change (e.g., Ncell adding UPI payments).
- Technology becomes obsolete (e.g., Daraz migrating from PHP to microservices).
- Regulations evolve (e.g., NEPSE’s new compliance rules for stock apps).
stateDiagram-v2
[*] --> Software_Deployment
Software_Deployment --> Maintenance_Phase: 70-80% of costs here!
Maintenance_Phase --> Corrective: Fix bugs
Maintenance_Phase --> Adaptive: Change environment
Maintenance_Phase --> Perfective: Improve performance
Maintenance_Phase --> Preventive: Avoid future issues
Maintenance_Phase --> Evolution: Major redesigns
Maintenance_Phase --> [*]Types of Software Maintenance
The syllabus divides maintenance into four categories, each with distinct goals and techniques.
1. Corrective Maintenance: Fixing the Broken
Definition: Identifying and repairing faults (bugs, crashes, security flaws) in live software. Example: When eSewa’s payment gateway failed during Dashain 2022 due to a race condition in transaction logging, developers had to patch the concurrency bug under pressure.
How It Works
- Problem Reporting: Users/file logs report issues (e.g.,
NullPointerExceptionin a Daraz order processing script). - Diagnosis: Use debuggers (GDB, Visual Studio Debugger), logging frameworks (Log4j), or static analysis tools (SonarQube).
- Fix: Write a patch (e.g., adding input validation).
- Testing: Regression testing to ensure the fix doesn’t break other features.
- Deployment: Hotfix (emergency) or scheduled update.
Real-World Trace: Pathao’s Driver App Crash
- Symptom: App crashes when GPS signal drops in Kathmandu’s narrow alleys.
- Root Cause: Unhandled
LocationManagerexceptions. - Fix: Added a fallback to cached locations + retry logic.
- Tool Used: Firebase Crashlytics for real-time crash analytics.
2. Adaptive Maintenance: Keeping Up with Change
Definition: Modifying software to adapt to changes in the environment (hardware, OS, laws, or user needs). Example: When NTC upgraded Nepal’s internet infrastructure to fiber, many websites had to update their HTTP request timeouts and compression algorithms.
Common Adaptation Scenarios
| Change Driver | Software Adaptation | Nepali Example |
|---|---|---|
| New OS version | Update API calls (e.g., Android 14’s permissions) | Khalti app supporting Android 14’s biometric auth |
| Hardware upgrade | Optimize for 64-bit or ARM processors | Daraz’s server migration to AWS Graviton |
| Regulatory compliance | Add GDPR/PDPA data encryption | eSewa’s PCI-DSS compliance for payments |
| User device shift | Responsive design for mobile vs. desktop | Ncell’s myNcell app for feature phones |
Worked Example: NEPSE’s API Changes
- Old System: REST API with JSON responses (2018).
- New Requirement: Real-time WebSocket updates for stock prices (2023).
- Adaptation:
- Added WebSocket endpoint
/live-prices. - Updated frontend to handle both REST and WebSocket.
- Tool: Postman for API versioning tests.
- Added WebSocket endpoint
3. Perfective Maintenance: Making It Better
Definition: Enhancing non-functional attributes (speed, security, usability) or adding new features without changing core functionality. Example: WhatsApp’s end-to-end encryption (2016) was a perfective maintenance—it didn’t break existing chats but added security.
Common Perfective Tasks
- Performance tuning: Optimizing SQL queries (e.g., Daraz’s MySQL indexes for product searches).
- Security patches: Fixing vulnerabilities (e.g., Heartbleed in OpenSSL).
- Usability improvements: Redesigning UI/UX (e.g., Khalti’s one-tap payment flow).
- Localization: Adding Nepali language support (e.g., Google Maps in Nepalese).
Visual: Before vs. After Optimization
flowchart LR
A["Slow Query: 'SELECT * FROM orders WHERE status='pending''"] -->|"Before"| B["1.2s response time"]
A -->|"After adding INDEX on status"| C["80ms response time"]4. Preventive Maintenance: Avoiding Future Problems
Definition: Proactively modifying software to prevent future failures or maintenance needs. Example: Google’s use of static analysis tools (like Error Prone) to catch bugs before they reach production.
Preventive Techniques
| Technique | How It Works | Example |
|---|---|---|
| Code refactoring | Improving structure without changing behavior | Converting spaghetti code to SOLID principles |
| Documentation updates | Keeping docs aligned with code | Swagger/OpenAPI specs for APIs |
| Automated testing | Unit/integration tests to catch regressions | Jest for JavaScript, Pytest for Python |
| Dependency updates | Patching libraries before vulnerabilities emerge | npm audit fix for Node.js packages |
Real-World Example: Pathao’s Microservices
- Problem: Monolithic app led to slow deployments.
- Prevention: Split into microservices (e.g.,
payment-service,ride-service) with Docker + Kubernetes. - Tool: SonarQube for continuous code quality checks.
Software Evolution: Beyond Maintenance
While maintenance is reactive, evolution is proactive—it involves major redesigns to meet new requirements or technologies.
Lehman’s Laws of Software Evolution
Three key principles (critical for exams!):
- Continuing Change: Software must evolve or become obsolete.
- Increasing Complexity: Without refactoring, systems grow harder to maintain.
- Self-Regulation: Markets drive evolution (e.g., WhatsApp replacing SMS).
Visual: Lehman’s Laws in Action
mindmap
root((Lehman's Laws))
Continuing_Change
Example: eSewa adding QR payments
Increasing_Complexity
Example: Monolithic apps → Microservices
Self_Regulation
Example: Ncell’s USSD → Mobile App shiftEvolution Strategies
| Strategy | Description | Nepali Example |
|---|---|---|
| Reengineering | Redesigning without changing functionality | Daraz’s move from LAMP to Node.js |
| Reverse Engineering | Analyzing existing code to understand design | Decoding old NTC billing software |
| Forward Engineering | Building new system from scratch | NEPSE’s new trading platform (2023) |
| Incremental Evolution | Small, frequent updates | WhatsApp’s yearly feature drops |
Worked Example: Khalti’s Evolution
- 2016: Basic mobile wallet (perfective maintenance).
- 2018: Added API for merchants (adaptive maintenance).
- 2020: Full banking-as-a-service platform (evolution).
- 2023: Integrated with NPCI’s RuPay (regulatory adaptive maintenance).
Maintenance vs. Evolution: Key Differences
| Aspect | Maintenance | Evolution |
|---|---|---|
| Goal | Keep software working as-is | Transform software for new needs |
| Scope | Fix bugs, adapt to changes | Redesign architecture, add major features |
| Risk | Low (controlled changes) | High (requires planning, testing) |
| Example | Patching a bug in Pathao’s ride app | Redesigning NEPSE’s trading system |
| Tools Used | Debuggers, log analyzers | UML, architecture diagrams, CI/CD pipelines |
In the Real World
eSewa’s API Maintenance
- Type: Adaptive + Perfective
- How: When NPCI mandated new encryption standards (2022), eSewa had to:
- Update their payment gateway to use AES-256 (adaptive).
- Add real-time fraud detection (perfective).
- Tool: Postman for API versioning tests + GitHub Actions for CI/CD.
WhatsApp’s End-to-End Encryption
- Type: Perfective Maintenance → Evolution
- How:
- 2014–2016: Added Signal Protocol for encryption (perfective).
- 2016–2023: Became a standard for messaging apps (evolution).
- Impact: Forced competitors (e.g., Telegram) to adopt similar security.
NTC’s Fiber Upgrade Challenges
- Type: Adaptive Maintenance
- Problem: Older ISPs’ software couldn’t handle 1Gbps speeds.
- Solution: NTC provided SDK updates for ISPs to optimize TCP window scaling and QoS policies.
- Tool: Wireshark for packet analysis during testing.
Challenges in Software Maintenance
| Challenge | Cause | Solution |
|---|---|---|
| Lack of Documentation | Developers move on; docs become outdated | Use Swagger/OpenAPI for APIs |
| Legacy Code | Unstructured spaghetti code | Refactoring (e.g., Strangler Pattern) |
| High Costs | Unplanned fixes, emergency patches | Preventive maintenance (automated tests) |
| User Resistance | Forced updates break workflows | Beta testing (e.g., WhatsApp’s feature rollouts) |
| Security Risks | Outdated libraries (e.g., Log4j) | Dependency scanning (Snyk, Dependabot) |
Tools for Maintenance and Evolution
| Category | Tools | Use Case |
|---|---|---|
| Version Control | Git, GitHub, GitLab | Track changes, collaborate |
| Debugging | GDB, Visual Studio Debugger, Chrome DevTools | Fix runtime errors |
| Profiling | Valgrind, New Relic, Datadog | Find performance bottlenecks |
| Testing | JUnit, Selenium, Postman | Regression testing |
| Refactoring | IntelliJ IDEA, VS Code Extensions | Clean up code structure |
| CI/CD | Jenkins, GitHub Actions, CircleCI | Automate builds/deployments |
Exam Tip
What Examiners Want to See
Definitions with Examples
- Don’t just say “corrective maintenance is fixing bugs.” Give a real example (e.g., “Like when Daraz’s checkout page crashed during Black Friday due to a race condition in the cart service”).
Lehman’s Laws
- Always relate them to Nepali software (e.g., “Ncell’s app becomes more complex each year because new features like UPI are added, following Lehman’s Increasing Complexity law”).
Tool Names
- Mention specific tools in answers:
- Debugging → GDB or Visual Studio Debugger
- Testing → Jest or Selenium
- Version control → GitHub Actions
- Mention specific tools in answers:
Comparison Tables
- Examiners love structured comparisons (e.g., maintenance vs. evolution, adaptive vs. perfective).
Real-World Scenarios
- Tie every concept to Nepal:
- “eSewa’s API updates are an example of adaptive maintenance because they had to change their system to comply with NPCI’s new security standards.”
- “Pathao’s driver app crashes during peak hours are fixed via corrective maintenance using Firebase Crashlytics.”
- Tie every concept to Nepal:
Common Pitfalls to Avoid
- ❌ Saying “maintenance is only about fixing bugs” (forgetting adaptive/perfective/preventive).
- ❌ Ignoring Lehman’s Laws—they’re a must-mention in TU/PU exams.
- ❌ Vague answers like “use tools.” Name the tool (e.g., “Use SonarQube for static analysis”).
- ❌ Skipping cost models (e.g., “Maintenance costs rise exponentially over time due to Lehman’s laws”).
Sample Exam Question & Answer
Question: “Explain the difference between adaptive and perfective maintenance with a Nepali example for each. How would you implement preventive maintenance for a banking app like NMB Bank’s mobile app?”
Model Answer: Adaptive and perfective maintenance differ in their primary goals:
- Adaptive maintenance adjusts software to external changes (e.g., new OS, hardware, or regulations).
- Example: When Nepal Rastra Bank mandated stronger KYC (Know Your Customer) rules in 2023, NMB Bank had to update their mobile app to include AI-based document verification (adaptive).
- Perfective maintenance improves non-functional aspects (speed, security, usability) or adds minor features without changing core functionality.
- Example: NMB Bank’s biometric login (fingerprint/face ID) was a perfective enhancement—it didn’t alter the banking core but improved user experience.
For preventive maintenance in NMB Bank’s app, I would:
- Refactor legacy code using IntelliJ IDEA’s refactoring tools to reduce technical debt.
- Implement automated testing with Selenium for UI and JUnit for backend to catch regressions early.
- Use static analysis tools like SonarQube to detect vulnerabilities (e.g., SQL injection risks) before deployment.
- Update dependencies regularly via Dependabot to patch security flaws (e.g., Log4j).
- Document APIs using Swagger to ensure future developers understand the system.
Visual Summary:
flowchart TD
A["Adaptive Maintenance"] -->|"Example"| B["NMB Bank's KYC Update"]
C["Perfective Maintenance"] -->|"Example"| D["NMB Bank's Biometric Login"]
E["Preventive Maintenance"] -->|"Tools"| F["SonarQube<br/>Selenium<br/>Dependabot"]Based on the TU BITM syllabus for Software Design and Development (IT242), unit 9.
Discussion
Loading…