Exercise: Composition vs inheritance

The CorrectCardsUseCase, SynchronizeCardsUseCase and SynchronizeUserUseCase classes share some functionalities:
  • Showing a progress bar (only CorrectCardsUseCase and SynchronizeCardsUseCase),
  • Handling network exceptions (only SynchronizeCardsUseCase and SynchronizeUserUseCase)
  • Showing a success dialog (only CorrectCardsUseCase and SynchronizeCardsUseCase)
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.