Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

CodeSignal

Refactoring by Leveraging Your Tests with C# & xUnit

via CodeSignal

Overview

Deep dive into the Refactor phase of TDD. Learn to spot code smells and apply refactoring techniques using real examples, while keeping tests passing to preserve functionality.

Syllabus

  • Unit 1: Eliminating Duplicated Code: Extract Functions and Refactor Magic Numbers
    • Refactor Duplicated 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 in C#
    • Extract user validation logic
    • Extracting validation into validator classes
    • Extract data normalization code
    • Setting our sights on the DataStore
  • 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: MoveMethod CalculateFinalGrade
    • Eliminate the GradeAnalyzer
    • Eliminate Feature Envy from the Student
  • Unit 5: Large Class: Extract Class
    • Extract a CartItemCollection
    • Extract the PriceCalculator class
    • Extract a DiscountCalculator class
    • Write Tests for Extracted Classes

Reviews

Start your review of Refactoring by Leveraging Your Tests with C# & xUnit

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.