Refactoring by Leveraging Your Tests with TypeScript & Jest
This course focuses on the Refactor step in TDD, teaching developers to spot code smells and resolve them through refactoring. Using real-world examples, you'll identify common issues, apply refactoring techniques, and ensure functionality is preserved with existing tests.
Lessons and practices
Refactor Duplicated Code in the Tests
Refactor Tests using Parameterization
Extract Function: calculateItemCost
Refactor duplication between calculate functions
Refactor Magic Numbers to Constants
Extract user validation logic
Extracting validation into validator classes
Extract data normalization code
Setting our sights on the DataStore
Extract Result Type
Streamline Parameters with a Parameter Object
Introduce a CoursePolicy parameter object
Re-order parameters for cohesion
Provide defaults for most parameters
Extract StudentGrade Logic
Refactor: MoveMethod calculateFinalGrade
Eliminate the GradeAnalyzer
Eliminate Feature Envy from the Student
Extract a CartItemCollection
Extract the PriceCalculator class
Extract a DiscountCalculator class
Write Tests for Extracted Classes
Interested in this course? Learn and practice with Cosmo!
Practice is how you turn knowledge into actual skills.