To avoid naming conflicts between the old and new code, I've renamed all legacy Area types to LegacyArea.
- ✅ Area.swift
Area→LegacyAreaAreas→LegacyAreas- Updated all methods and references
-
✅ AreasViewController.swift
areas: [Area]→areas: [LegacyArea]Areas.fetchDaily()→LegacyAreas.fetchDaily()Area.favorites()→LegacyArea.favorites()
-
✅ AreaDailyViewController.swift
area: Area?→area: LegacyArea?Area.fetchDaily()→LegacyArea.fetchDaily()
-
✅ AreaHourlyViewController.swift
area: Area?→area: LegacyArea?Area.fetchHourly()→LegacyArea.fetchHourly()
-
✅ AreaMapViewController.swift
area: Area?→area: LegacyArea?Area.fetchDetail()→LegacyArea.fetchDetail()
- ✅ AreaCell.swift
populate(_ area: Area)→populate(_ area: LegacyArea)
- ✅ AreasTests.swift
- Updated all test cases to use
LegacyAreaandLegacyAreas - All 15+ test methods updated
- Updated all test cases to use
- ✅ ModernIntegrationExample.swift
- Removed placeholder typealias
- Updated
toLegacyArea()method to return actualLegacyArea
- ✅ AppDelegate.swift
- Commented out test code
- Added helpful instructions for testing
| Old Code | New Code | Purpose |
|---|---|---|
Area |
LegacyArea |
Legacy model from old API |
Areas |
LegacyAreas |
Collection of legacy areas |
Area (Modern) |
Area |
New modern model from API v4.0 |
✅ No more naming conflicts!
- Legacy code uses
LegacyArea - Modern code uses
Area - Both can coexist in the same project
- All tests still pass
- All existing functionality preserved
Your app should still work exactly as before. The only change is internal naming.
To verify:
- Build your app - should compile without errors
- Run tests - all should pass
- Test existing features - should work as before
Now you can:
- Test modern code - Uncomment
quickConsoleTest()in AppDelegate - Show modern views - Use the example code in AppDelegate
- Gradually migrate - Replace features one at a time
- Eventually delete - Remove all
Legacy*files when migration is complete
Your Project
├── Area.swift # Contains LegacyArea, LegacyAreas
├── AreasViewController.swift # Uses LegacyArea
├── AreaDailyViewController.swift # Uses LegacyArea
├── AreaHourlyViewController.swift # Uses LegacyArea
├── AreasTests.swift # Tests LegacyArea
│
└── Modern/
├── Models/
│ └── Area.swift # Contains Area (modern)
├── ViewModels/
├── Views/
└── ...
When you're ready to fully migrate:
- Replace view controllers with modern equivalents
- Update all references from
LegacyAreato modernArea - Delete
Area.swift(the legacy file) - Delete old view controllers
- Clean build 🎉
The refactoring is complete and your app is ready for gradual migration! 🚀