Refactor with Factory Design Pattern
summary
Refactors a sprawling switch-based CSV importer into a class-per-format solution using a Factory pattern that returns objects implementing a schedule type interface with methods to detect type, format dates, extract lines, check duplicates and yield time slots. Built as CakePHP classes (inheritance, traits, collections) and a thin controller/behavior, it produces a CakePHP ORM entity that parses three real formats. Unit tests run the same data provider against legacy and refactored code and show matching 20, 9, 8 results, proving the refactor works.
AI-written summary · about
chapters (6)
- 0:00Introduction and context
- 2:13Legacy code challenges
- 5:37Analyzing the legacy logic
- 10:26Implementing the factory
- 16:34Refactoring the controller
- 20:21Validation and unit tests
related talks
57mRefactoring a large legacy PHP Application: a case study
38mCakePHP Test Fixture Factories
42mObject reorientation
38mLaravel Design Patterns
02h 53mPractical design patterns in PHP (Part 3)
21mSoftware Design Patterns in Laravel 4
28mReformat, Refactor, Replace: A practical guide for dealing with legacy software
40mRefactoring Huge Legacy PHP Applications - From 100 hours to minutes
