London | 26-SDC-March | Zobeir Rigi | Sprint 5 | prep-exercises#536
London | 26-SDC-March | Zobeir Rigi | Sprint 5 | prep-exercises#536Zobeir-Rigi wants to merge 12 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Good work on these tasks, just one part where code could be improved and another where explanation could be improved.
| preferred_os = parse_os(os_input) | ||
|
|
||
| except ValueError as e: | ||
| print(f"Error: {e}", file=sys.stderr) |
There was a problem hiding this comment.
If you get an input error, is there a user friendly way to handle this without exiting the program?
There was a problem hiding this comment.
If you get an input error, is there a user friendly way to handle this without exiting the program?
I handled input errors by retrying in a loop instead of exiting, so users can fix mistakes without restarting.
| # Encapsulation | ||
| # The class controls its own logic | ||
| # Example: You change from age → date_of_birth | ||
| # Only the class needs to change, External code still works:person.is_adult() |
There was a problem hiding this comment.
Could you expand on this point, what do you mean by "external code still works"?
There was a problem hiding this comment.
Could you expand on this point, what do you mean by "external code still works"?
It means we can change the internal implementation inside the class to modify the method’s behaviour, without changing how external code uses it, for example person.is_adult() stays the same.
sprint 5 - prep exercises, learned about type in Python, mypy, and OOP.