PythonDataScience24 / GymGenie

Advance Python Project
MIT License
0 stars 0 forks source link

Reuse of code in goal_summary.py #5

Open StroboBrain opened 1 month ago

StroboBrain commented 1 month ago

Following match statement used several times in your GoalSummery class. Starting at line 154, 205, 252, 301, 457, 507, 552, 598.

example from your code

        match unit_value:
            case "kcal":
                unit = 'calories'
            case "km":
                unit = 'distance'
            case "min":
                unit = 'duration'

To reduce the lines of code, I suggest to turn this match statement into a function. This would reduce the amount of lines in your code.

your code refactored as function get_unit

def get_unit(unit_value: str)-> str:
    match unit_value:
            case "kcal":
                unit = 'calories'
            case "km":
                unit = 'distance'
            case "min":
                unit = 'duration'
    return unit

Additional Feedback

The main.py class runs perfectly after I cloned your repository.

ddd42-star commented 1 month ago

Hey @StroboBrain

thank you for the suggestion. The last milestone was a bit hectic and we didn't clean up most of the code.