Level 88 - Complex Business Logic Simplification
Table of Contents
Interview Question
"You're refactoring a legacy payment processing program with 3,000 lines of spaghetti code. You find this pattern repeated 50+ times:
IF TRAN-CODE = 'CHK' OR TRAN-CODE = 'ACH' OR
TRAN-CODE = 'WIR' OR TRAN-CODE = 'EFT'
PERFORM ELECTRONIC-PAYMENT
ELSE
IF TRAN-CODE = 'CSH' OR TRAN-CODE = 'MNY'
PERFORM CASH-PAYMENT
ELSE
IF TRAN-CODE = 'CRD' OR TRAN-CODE = 'DEB'
PERFORM CARD-PAYMENT
ELSE
PERFORM ERROR-HANDLING
END-IF
END-IF
END-IF.
Business rules:
- Electronic: CHK, ACH, WIR, EFT, RTG (new), FED (new)
- Cash: CSH, MNY
- Card: CRD, DEB, CCP (new)
- Rules change quarterly (new codes added)
Redesign using Level 88. Show before/after code and explain maintainability benefits."
What This Tests
- Advanced COBOL techniques
- Code maintainability awareness
- Understanding of condition names
- Ability to simplify complex logic
Good Answer Should Include
1. Refactored Data Division:
01 TRAN-DETAILS.
05 TRAN-CODE PIC X(3).
88 ELECTRONIC-TRAN VALUE 'CHK' 'ACH' 'WIR'
'EFT' 'RTG' 'FED'.
88 CASH-TRAN VALUE 'CSH' 'MNY'.
88 CARD-TRAN VALUE 'CRD' 'DEB' 'CCP'.
88 VALID-TRAN VALUE 'CHK' 'ACH' 'WIR'
'EFT' 'RTG' 'FED'
'CSH' 'MNY' 'CRD'
'DEB' 'CCP'.
2. Simplified Procedure Division:
EVALUATE TRUE
WHEN ELECTRONIC-TRAN
PERFORM ELECTRONIC-PAYMENT
WHEN CASH-TRAN
PERFORM CASH-PAYMENT
WHEN CARD-TRAN
PERFORM CARD-PAYMENT
WHEN OTHER
PERFORM ERROR-HANDLING
END-EVALUATE.
3. Benefits Explained:
- Maintainability: Add new codes in one place (data division)
- Readability: Self-documenting code (ELECTRONIC-TRAN vs. multiple ORs)
- Testing: Easier to verify all valid codes covered
- Performance: Compiler optimizes Level 88 conditions
- Error reduction: Can't forget to add code in one place and miss others
4. Advanced Usage:
* Validation
IF NOT VALID-TRAN
PERFORM ERROR-HANDLING
END-IF.
* Setting values
SET ELECTRONIC-TRAN TO TRUE * Sets TRAN-CODE to 'CHK'
5. Maintenance Process:
- When new code added: Update Level 88 definition only
- All 50 instances automatically updated
- No risk of missing one instance
Red Flags
- ❌ Just reduces nested IFs without using Level 88
- ❌ Doesn't understand SET verb with Level 88
- ❌ Can't articulate maintainability benefits
- ❌ Doesn't mention testing or validation improvements
Follow-Up Questions
- "Can you have multiple Level 88s for the same field?"
- "What happens if you SET ELECTRONIC-TRAN when TRAN-CODE already has 'CRD'?"
- "How would you test that all valid transaction codes are covered?"
- "What if transaction codes need hierarchy (ELECTRONIC-TRAN includes DOMESTIC-TRAN and INTL-TRAN)?"
Difficulty Level
Mid to Senior
Relevant Roles
Developer, Technical Lead, Architect