Skip to content

Instantly share code, notes, and snippets.

@adenhaus
Created January 12, 2021 15:30
Show Gist options
  • Save adenhaus/f648b0d4e534903d74e234babbea9e0c to your computer and use it in GitHub Desktop.
Save adenhaus/f648b0d4e534903d74e234babbea9e0c to your computer and use it in GitHub Desktop.
Example of how naming drives removing duplication (before refactoring)
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