
Exercise: Composition vs inheritance
The CorrectCardsUseCase, SynchronizeCardsUseCase and SynchronizeUserUseCase classes share some functionalities:
- Showing a progress bar (only
CorrectCardsUseCaseandSynchronizeCardsUseCase), - Handling network exceptions (only
SynchronizeCardsUseCaseandSynchronizeUserUseCase) - Showing a success dialog (only
CorrectCardsUseCaseandSynchronizeCardsUseCase)
Extract this repeating code using:
- Inheritance
- Composition
Compare these two approaches.
You can find those classes in the repository MarcinMoskala/kotlin-exercises in the package effective.anki.