Sprout techniques involve creating new methods or classes to encapsulate additional functionality or refactored behavior. These techniques help to safely introduce changes while preserving existing behavior, minimizing risks, and improving testability. In this course we will use sprout techniques with methods and objects to refactor or expand capabilities.
Overview
Syllabus
- Unit 1: Sprout Method - Reducing Risk of Adding New Features
- Sprouting a New Order Processing Method
- Testing Order Processing with Surcharges
- Testing Empty Orders with Surcharges
- Testing Negative Surcharges with Theory
- Testing Order Processing with Surcharges
- Unit 2: Sprout Method - When a Method Does Too Much
- Extract Customer Lookup Method
- Extract Order Calculation Logic
- Extract Payment Logic for Better Code
- Extract Order Status Update Method
- Extract Email Confirmation Method
- Unit 3: Wrap Method - Safely Adding New Behaviors
- Extract Method Refactoring Pattern
- Adding Fraud Detection to OrderProcessor
- Using the New Dependency to Prevent Fraud
- Testing Fraud Detection with Mocks
- Testing Order Processing Without Fraud
- Unit 4: Sprout Class - When Classes Do Too Much
- Creating a Metrics Collector Class
- Order Metrics Collection System
- Adding Metrics Collector Field
- Metrics Collection Refactoring
- Unit 5: Sprout Class - When New Shouldn't Affect Old
- Enhancing Order System with Customer Features
- Loyalty Rewards for Valued Customers
- Building a Discount Order Processor
- Discount Processing for Loyal Customers
- Unit 6: Wrap Class - Expanding Whole Class Behavior
- Create Interface for Order Processing
- Creating the new Order Processor that Logs Events
- Adding Logs to Order Processing
- Complete the Order Cancellation Logger