Software EngineeringUnit 611 min read
Software Quality: Metrics, Assurance & Control
Unit 6 of Software Engineering covers quality metrics (ISO 25010, McCabe, Halstead), verification vs. validation, inspection techniques, defect prevention, configuration management, and ethical compliance—with real-world examples from Nepali apps (e.g., eSewa’s transaction validation) and global systems (Google’s SRE p
TAKEAWAYS:
- Quality ≠ correctness: ISO 25010 defines 8 quality characteristics (functional suitability, reliability, usability, etc.) measured via metrics like cyclomatic complexity and defect density.
- Verification vs. Validation: Verification checks if the product meets specs (e.g., code reviews); validation checks if it meets user needs (e.g., beta testing with eSewa users).
- Inspections > Testing: Formal Fagan inspections (4–6 people) catch 60–90% of defects early—critical for safety-critical systems like NTC’s billing software.
- Configuration Management (CM): Tracks changes via baselines, version control (Git), and build automation—used by Daraz to roll back faulty releases.
- Ethics in SE: Violations (e.g., selling user data like Pathao’s past leaks) breach ACM/IEEE codes; whistleblowing is legally protected in Nepal’s IT Act 2008.
- COCOMO Model: Predicts effort (person-months) for projects; embedded mode (e.g., Ncell’s billing system) requires 2.4× more effort than organic mode.
1. Defining Software Quality
Software quality is the degree to which a system satisfies stated and implied needs (ISO/IEC 25010). It’s not just bug-free code—it’s about reliability, usability, and maintainability.
Key Quality Characteristics (ISO 25010)
Why it matters:
- eSewa’s transaction system must guarantee functional suitability (correct deductions) and security (no fraud).
- Pathao’s app prioritizes usability (intuitive UI) and performance (fast ride matching).
2. Quality Metrics: Measuring What Matters
Metrics quantify quality attributes. Two critical types:
A. Product Metrics (Static Analysis)
Measured without executing the code. Examples:
McCabe’s Cyclomatic Complexity (V(G))
- Measures logical complexity in code.
- Formula: where = edges, = nodes, = connected components.
- Threshold: < 10 (simple), 10–20 (moderate), >20 (complex/refactor).
- Example:
Here, (low complexity).if (x > 0) { // Node 1 if (y < 5) { // Node 2 z = a + b; // Edge 1-2 } else { z = a - b; // Edge 1-3 } } else { z = 0; // Edge 1-4 }
Halstead’s Software Science
- Predicts effort and bugs using:
- = unique operators (e.g.,
+,if) - = unique operands (variables)
- = total operators
- = total operands
- = unique operators (e.g.,
- Program Length:
- Vocabulary:
- Volume:
- Example: For
int sum = a + b;, (int,+), (sum,a,b), , .
- Predicts effort and bugs using:
B. Process Metrics (Dynamic Analysis)
Measured during development/testing:
- Defect Density: Defects per KLOC (thousand lines of code).
- Example: If a 100-KLOC system has 50 defects, density = 0.5 defects/KLOC.
- Industry Benchmark: < 1.0 (high quality).
- Mean Time Between Failures (MTBF): Critical for NTC’s network software or Ncell’s call routing.
3. Verification vs. Validation: The Critical Distinction
| Aspect | Verification | Validation |
|---|---|---|
| Focus | Are we building the product right? | Are we building the right product? |
| When | During development (e.g., code reviews) | After development (e.g., user testing) |
| Example (eSewa) | Checking if a transaction ID is unique | Testing if users can pay bills easily |
| Tools | Static analyzers, unit tests | Beta testing, A/B testing |
| Risk if Failed | Buggy but "correct" code | Product fails to meet user needs |
Real-World Trace:
- Nepal Rastra Bank’s core banking system:
- Verification: Auditors check if interest calculations (e.g., ) match RBI guidelines.
- Validation: Bank staff test if loan officers can process applications without errors.
4. Inspection Process: Catching Defects Early
Fagan Inspection (a formal review process) involves 4–6 people and 6 steps:
stateDiagram-v2 [*] --> Planning: "Moderator + author select documents" Planning --> Overview: "Team reviews goals" Overview --> Preparation: "Individuals study code" Preparation --> Meeting: "Discuss defects" Meeting --> Rework: "Author fixes issues" Rework --> Follow-up: "Verify fixes" Follow-up --> [*]
Why inspections work:
- eSewa’s payment gateway uses inspections to catch SQL injection flaws before deployment.
- Defect removal efficiency: Inspections find 60–90% of defects vs. 30% via testing.
5. Configuration Management (CM): Controlling Change
CM ensures consistency across software versions. Key activities:
- Version Control: Track changes (e.g., Git for Daraz’s app updates).
- Baselining: Freeze a version (e.g., NTC’s billing software v1.2).
- Build Automation: Tools like Jenkins compile/test code automatically.
- Release Management: Control deployments (e.g., Pathao’s nightly rollouts).
Example: Daraz’s Order Queue System
- Problem: A bug in v3.2 caused order duplicates.
- CM Solution:
- Rollback: Reverted to v3.1 using Git tags.
- Hotfix: Patched v3.2 with a new baseline.
6. Software Ethics: Protecting Users and Developers
Ethical violations in Nepal:
- Pathao (2018): Sold user location data to third parties → ACM Code Violation (privacy breach).
- Nepal Stock Exchange (NEPSE): Insider trading via unethical access to trading algorithms.
ACM/IEEE Ethical Guidelines:
- Public: Avoid harm to users (e.g., Ncell’s net neutrality).
- Client/Employer: Honor contracts (e.g., eSewa’s data-sharing agreements).
- Product: Ensure software is reliable and secure.
- Judgment: Disclose conflicts of interest (e.g., a Daraz dev owning a competing app).
Whistleblowing in Nepal:
- Protected under IT Act 2008 (Section 49).
- Example: An NTC engineer reporting billing software fraud is legally safe.
7. COCOMO Model: Estimating Effort and Time
Constructive Cost Model (COCOMO) predicts effort for projects. Three modes:
| Mode | Project Type | Effort (KDSI) | Time (Months) | Example |
|---|---|---|---|---|
| Organic | Small team, familiar tech | eSewa’s MVP | ||
| Semi-Detached | Medium team, some constraints | Khalti’s UPI integration | ||
| Embedded | Complex, real-time | NTC’s core network software |
Worked Example: A project is 320 KLOC (Kilo Lines of Code).
- Organic Mode:
- Effort = person-months.
- Time = months.
- Embedded Mode:
- Effort = person-months.
- Time = months.
Real-World Tie-In:
- Ncell’s billing system (embedded mode) took 32 months vs. eSewa’s organic-mode MVP (26 months).
8. Risk Management in Quality
Quality risks arise from:
- Poor requirements (e.g., NEPSE’s delayed trading system).
- Technical debt (e.g., Pathao’s legacy code crashes).
- External dependencies (e.g., Daraz relying on Ncell’s API).
Risk Analysis Steps:
- Identify: List risks (e.g., "Database corruption").
- Assess: Probability × Impact (e.g., 0.7 × High = Critical).
- Mitigate: Actions like backups (NTC), load testing (eSewa).
In the Real World
eSewa’s Transaction Validation
- Quality Idea: Validation ensures users can pay bills without errors.
- How: Beta tests with 500+ users before full rollout.
- Metric Used: Defect density < 0.3/KLOC in production.
NTC’s Network Reliability
- Quality Idea: Reliability (MTBF) must exceed 99.99%.
- How: Fagan inspections on routing protocols; automated regression tests.
- Real Picture: IMAGE: "NTC fiber optic cable installation" | Underground fiber links ensuring low latency.
Pathao’s Ride-Matching Algorithm
- Quality Idea: Performance efficiency (response time < 2s).
- How: McCabe complexity kept below 10 for critical modules.
- Ethics Violation: 2018 data leak breached ACM’s "Public" principle.
Exam Tip
COCOMO Questions:
- Always show step-by-step calculations (e.g., ).
- Memorize mode multipliers (Organic: 2.4, Embedded: 3.6).
Verification vs. Validation:
- Verification = Specs (e.g., "Does the code match the design?").
- Validation = Users (e.g., "Can farmers use eSewa on feature phones?").
Inspection Process:
- 6 steps: Planning → Overview → Preparation → Meeting → Rework → Follow-up.
- Defect catch rate: 60–90% (vs. 30% for testing).
Ethics:
- ACM Code: Public, Client, Product, Judgment.
- Nepal Law: IT Act 2008 protects whistleblowers.
Metrics:
- Cyclomatic Complexity: .
- Defect Density: Defects/KLOC (<1.0 is good).
CM Activities:
- Version Control (Git), Baselining, Build Automation (Jenkins).
Pro Tip: For short-answer questions, use bullet points and real examples (e.g., "Like eSewa’s validation tests..."). For long answers, structure with headings and diagrams. Always tie theory to Nepali apps (eSewa, NTC, Daraz).
Based on the TU BSc CSIT syllabus for Software Engineering (CSC364), unit 6.
Discussion
Loading…