You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor: Apply SRP to Calorie Calculator application
Separated concerns into multiple classes to adhere to the Single
Responsibility Principle:
- UserData: New DTO to hold user input.
- UserInputHandler: Handles all console input operations and
basic input validation.
- CalorieCalculator: (Formerly CalorieCalculationService) Now solely
responsible for BMR and daily calorie needs calculations.
Contains all business logic for these computations.
- ResultDisplay: Manages formatting and display of calculation
results to the console.
- MainApp: Orchestrates the application flow, coordinating between
the input, calculation, and display components.
This refactoring improves modularity, testability, and maintainability
of the codebase. The original CalorieCalculator class, which previously
handled multiple responsibilities (UI, validation, calculation), has
had its calculation logic extracted into the new, focused
CalorieCalculator class, and its other responsibilities moved to
UserInputHandler, ResultDisplay, and MainApp.
0 commit comments