Refactor the TripService
class to ensure Clean Code / SOLID principles
Legacy code golden rules :
You cannot change any existing code if not covered by tests.
The only exception is if we need to change the code to add unit tests, but in this case, just automated refactorings (via IDE) are allowed.
- Start testing from shortest to deepest branch
- Start refactoring from deepest to shortest branch
- Cover the production code
- Improve confidence in our tests
- Refactor the production code
- Other refactorings
Seams
Automated refactoring
via our IDE- Extract Method
- Change Signature
- Rename
Mutation Testing
- Use
Higher Order Functions
to avoid duplication - Use
code coverage
as a driver Test Data Builder
Feature Envy
Sprout Class
TDD
Sources :