Bank Account Classification Analysis
Overview
This case study demonstrates how seemingly minor feature additions can create exponential growth in testing complexity. By comparing two versions of bank account classification logic—one basic and one with a simple balance check—we reveal hidden complexity that traditional testing would miss.
The Shocking Result
Adding one simple balance check increased testing complexity by 190%:
- Code grew by 21% (167 → 203 lines)
- Regions grew by 190% (19 → 55 behavioral regions)
- Test cases needed: 2.9x more
The Business Problem
Context
Financial institutions must classify deposit accounts as "transactional" or "non-transactional" for:
- Regulatory capital requirements
- Interest rate calculations
- Fee structures
- Customer eligibility
Misclassification can result in:
- ❌ Regulatory non-compliance and penalties
- ❌ Incorrect risk assessments
- ❌ Customer complaints and reputational damage
- ❌ Revenue leakage
The Classification Rules
Basic Classification Logic
An account qualifies as transactional if it meets ALL of these criteria:
- Product Eligibility
Account type must be one of:
- Transaction
- CMA_Direct
- CMA_Platform
- BB_Cheque_Account
- BB_Regulated_Trust_Account
- Active Use Test - Inflows
At least 3 depositor-initiated inflows (credits) within the lookback period
- Active Use Test - Outflows
At least 3 depositor-initiated outflows (debits) within the lookback period
Result: 19 Behavioral Regions
- ✓ 3 decision criteria
- ✓ 6 product types × activity combinations
- ✓ Manageable with traditional testing
The Solution: Region Decomposition
CodeLogician's formal verification reveals all 55 behavioral regions automatically, ensuring complete test coverage.
How It Works
Basic Version: 19 Regions
View Sample Regions from Basic Version
| Region | Product Type | Inflows ≥3 | Outflows ≥3 | Result |
|---|---|---|---|---|
| 0 | Transaction | ✓ | ✓ | Transactional |
| 1 | CMA_Direct | ✓ | ✓ | Transactional |
| 5 | Other | ✓ | ✓ | Not Transactional |
| 6 | Transaction | ✓ | ✗ | Not Transactional |
... and 15 more regions | ||||
Enhanced Version: 55 Regions
The enhanced version adds balance-related regions:
Zero Balance Regions
Special case: balance = 0 automatically passes threshold check. Creates separate regions for each product type.
Below Threshold Regions
balance × (100 + rate) ≤ $25M. Different (balance, rate) combinations produce different regions.
Exceeds Threshold Regions
balance × (100 + rate) > $25M. Accounts fail transactional classification regardless of other criteria.
Key Results
Coverage Guarantee
Mathematical Guarantee
Region decomposition provides mathematical certainty that all behavioral regions are covered—not just high code coverage, but complete logical coverage of the decision space.
Business Value
❌ Without Formal Verification
- Manual test case design: Days of effort
- Likely to miss edge cases: High risk
- No guarantee of completeness
- Bugs found in production: Weeks/months later
- Regulatory penalties and customer complaints
✅ With CodeLogician
- Automated region discovery: Minutes
- All 55 regions identified: 100% coverage
- Mathematical proof of completeness
- Bugs caught before production: Immediate
- Confidence in classification logic: Guaranteed
Broader Applications
This approach applies to any business logic with:
✅ Complex Decision Trees
Multiple conditions combined with AND/OR logic
✅ Threshold-Based Rules
Financial limits, regulatory thresholds, risk scores
✅ Arithmetic Calculations
Interest calculations, fee computations, balance projections
✅ State-Dependent Behavior
Different rules based on account state, transaction history
✅ Regulatory Requirements
Rules that must be proven correct for compliance
✅ Classification Systems
Customer segmentation, risk categorization, product eligibility
Industry Examples
- Banking: Credit risk scoring, transaction monitoring, account classification, KYC rules
- Insurance: Premium calculations, claims adjudication, underwriting rules, coverage determination
- Trading: Order validation, margin calculations, compliance checks, position limits
- Healthcare: Eligibility determination, billing rules, clinical decision support, dosage calculations
- Government: Benefit calculations, tax rules, eligibility verification, grant approvals
Resources
Download the Code
Download Notebooks
Key Takeaways
Complexity Is Hidden
Traditional Testing Is Insufficient
The 55 behavioral regions would be nearly impossible to identify through manual test case design. Edge cases would inevitably be missed.
Formal Methods Are Practical
Discover hidden complexity in your business logic
Use CodeLogician to systematically analyze your critical code and ensure complete test coverage.