Skip to content

Instantly share code, notes, and snippets.

@up1
Last active August 29, 2015 14:22
Show Gist options
  • Save up1/011da277d9cd1041de8b to your computer and use it in GitHub Desktop.
Save up1/011da277d9cd1041de8b to your computer and use it in GitHub Desktop.
Refactoring :: Rule of Three
private void askQuestion() {
if (currentCategory() == "Pop")
System.out.println(pop.removeFirst());
if (currentCategory() == "Science")
System.out.println(science.removeFirst());
if (currentCategory() == "Sports")
System.out.println(sport.removeFirst());
if (currentCategory() == "Rock")
System.out.println(rock.removeFirst());
}
private void askQuestion() {
if (currentCategory() == "Pop") {
Object message = pop.removeFirst();
System.out.println(message);
}
if (currentCategory() == "Science") {
Object message = science.removeFirst();
System.out.println(message);
}
if (currentCategory() == "Sports") {
Object message = sport.removeFirst();
System.out.println(message);
}
if (currentCategory() == "Rock") {
Object message = rock.removeFirst();
System.out.println(message);
}
}
private void askQuestion() {
if (currentCategory() == "Pop") {
Object message = pop.removeFirst();
showMessageOnConsole(message);
}
if (currentCategory() == "Science") {
Object message = science.removeFirst();
showMessageOnConsole(message);
}
if (currentCategory() == "Sports") {
Object message = sport.removeFirst();
showMessageOnConsole(message);
}
if (currentCategory() == "Rock") {
Object message = rock.removeFirst();
showMessageOnConsole(message);
}
}
private void askQuestion() {
if (currentCategory() == "Pop") {
showMessageOnConsole(pop.removeFirst());
}
if (currentCategory() == "Science") {
showMessageOnConsole(science.removeFirst());
}
if (currentCategory() == "Sports") {
showMessageOnConsole(sport.removeFirst());
}
if (currentCategory() == "Rock") {
showMessageOnConsole(rock.removeFirst());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment