This a Code Smells Refactoring Kata, designed to teach developers how to identify, protect against, and refactor code smells using the classic "Gilded Rose" kata.
This is part of a 3-session hands-on training series:
- Detect - Identifying code smells
- Protect - Building safety nets with characterization and mutation testing
- Correct - Safe refactoring techniques
Please see the language specific folders for tech stack and set up instructions.
The main class is deliberately written poorly to demonstrate multiple code smells:
- Long Method - The
Process()
method is overly complex (102+ lines) - Magic Numbers - Constants like
FORTY_TWO = 42
andFIFTY = FORTY_TWO + 7
- Dead Code - Unused variables, unreachable branches, no-op operations
- Bad Names - Cryptic variable names like
ls
,w
,v
- Ticket Chatter - Comments with developer conversations and TODO items
- Primitive Obsession - Using raw strings instead of enums for item types
- Conditional Complexity - Deeply nested if-else statements (6 levels deep)
- Duplication - Repeated quality adjustment logic
- Swallowed Exceptions - Empty catch blocks
- Misleading Code - Assignment in conditionals (
experimentalFlag = true
)
Students learn to:
- Spot unhealthy code patterns using C# analyzers and linters
- Write characterization tests using NUnit to lock in existing behavior
- Use mutation testing with Stryker.NET to strengthen test coverage
- Apply safe refactoring techniques using Visual Studio/Rider refactoring tools
- Transform messy legacy code into clean, maintainable C# code
This provides an excellent hands-on learning environment for developers wanting to improve their refactoring skills and code quality awareness!