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.
Overview
Syllabus
- Unit 1: Eliminating Duplicated Code: Extract Functions and Refactor Magic Numbers
- Refactor Duplicate Code in the Tests
- Refactor Tests using Parameterization
- Extract Function: calculateItemCost
- Refactor Duplication between Calculate Functions
- Refactor Magic Numbers to Constants
- Unit 2: Refactoring Long Methods with the Extract Method Technique
- Extract User Validation
- Extracting Validation into Validator Classes
- Extract Data Normalization
- Focusing on the Data Store
- Unit 3: Long Parameter List: Introduce Parameter Object
- Streamline Parameters with a Parameter Object
- Introduce a CoursePolicy Parameter Object
- Re-order Parameters for Cohesion
- Provide Defaults for Most Parameters
- Unit 4: Feature Envy: Move Method Refactoring with TDD
- Extract StudentGrade Logic
- Refactor: Move Method calculateFinalGrade
- Getting rid of the GradeAnalyzer
- Eliminate Feature Envy from the Student
- Unit 5: Large Classes: Extract Class Refactoring
- Extract a CartItemCollection
- Extract a PriceCalculator Class
- Refactor ShoppingCart to Use DiscountCalculator Class
- Write Tests for Extracted Classes