Created
January 12, 2021 15:30
-
-
Save adenhaus/f648b0d4e534903d74e234babbea9e0c to your computer and use it in GitHub Desktop.
Example of how naming drives removing duplication (before refactoring)
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
public class DuplicationExample { | |
String buildingType; | |
public static void classifyBuilding(int floors) { | |
if (floors < 5) { | |
buildingType = "house"; | |
} else if (floors < 10) { | |
buildingType = "short"; | |
} else if (floors < 20) { | |
buildingType = "tall"; | |
} else if (floors < 40) { | |
buildingType = "very tall"; | |
} else { | |
buildingType = "skyscraper"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment