Conversation
In this updated version i basically re-structured the program and try to implement the DRY principle.
Author
|
In this updated version I basically re-structured the program and try to implement the DRY principle. and made the code more easy to understandable. |
irenemrtinez
left a comment
There was a problem hiding this comment.
Hi @CodeAKB :)
Thanks for submitting this PR! I have reviewed the changes, and I have a few observations and suggestions:
1. DRY Principle & Code Duplication
- Refactoring Logic: While moving from a
switchstatement toCharacter.toLowerCase()reduces case-sensitivity boilerplate, the overall structure remains similar. TheSystem.out.printfcalls are still repeated across all conditional branches. - Legacy Duplication: Notice that in both the original code and this PR, the core issue of repeating the formatting logic 6 times remains.
- Suggestion: To make it truly DRY, we could first normalize any input temperature to a single base unit (like Celsius). From there, we can compute and print the converted values from a single place without repeating
printfstatements.
2. Existing Issues Carried Over (Legacy Code)
(These issues were present in the original codebase as well, but it might be worth addressing them if we are refactoring this class)
-
Naming Conventions: Method names like
RunTemperatureConverter()start with a capital letter. In Java, standard conventions usecamelCase(e.g.,runTemperatureConverter()). -
Input Validation & Exception Handling: If a user inputs a non-numeric value, the program throws an unhandled
InputMismatchException. -
Physical Limits: The program currently accepts temperatures below Absolute Zero (
$0\text{ K}$ or$-273.15^\circ\text{C}$ ). Adding a quick validation check would make the converter much more robust.
I hope this was a useful review! If you make any changes, I would be happy to review them again. :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this updated version i basically re-structured the program and try to implement the DRY principle.