Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Overkill

 Overkill

When is it okay to build an orbital laser to destroy an ant-hill?

Many cry "overkill" when design principles are applied to trivial problems. And for good reason: in the context of work, excessive embellishment gets us into trouble. Complexity costs us time and money.

This talk explores how stepping outside of the realm of work and applying outrageous engineering practices to toy problems can deepen our understanding of the trade-offs that we make. Comically simple problems provide the perfect ground for developing actionable heuristics which can be applied to those monstrous complexities that we face in the real world.

Katrina Owen

April 03, 2014
Tweet

More Decks by Katrina Owen

Other Decks in Programming

Transcript

  1. README Bob answers 'Sure.' if you ask him a question.

    He answers 'Whoa, chill out!' if you yell at him. He says 'Fine. Be that way!' if you address him without actually saying anything. He answers 'Whatever.' to anything else.
  2. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." Iteration #1
  3. return"Whoa, chill out!" elsif input == "Ending with ? means

    a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno return"Whatever." end end end Iteration #1
  4. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end Iteration #1
  5. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end Iteration #1
  6. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end Iteration #1
  7. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end Iteration #1
  8. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end Iteration #1
  9. Iteration #1 class Bob def hey (input ) if input=="Tom-ay-to,

    tom-aaaah-to." return"Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end
  10. class Bob def hey(input) if input == "Tom-ay-to, tom-aaaah-to." return

    "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end Iteration #1 class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input =="1, 2, 3" return "Whatever." elsif input=="4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return"Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input== "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input=="" return"Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input==" " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return"Whatever." end end end
  11. Iteration #2 class Bob def hey(input) if input == "Tom-ay-to,

    tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure."
  12. Iteration #2 class Bob def hey(input) if input == "Tom-ay-to,

    tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end
  13. Iteration #2 class Bob def hey(input) if input == "Tom-ay-to,

    tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end
  14. Iteration #2 class Bob def hey(input) if input == "Tom-ay-to,

    tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end
  15. Iteration #2 class Bob def hey(input) if input == "Tom-ay-to,

    tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end
  16. Iteration #2 class Bob def hey(input) case input when "Tom-ay-to,

    tom-aaaah-to." "Whatever." when "WATCH OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end end end class Bob def hey(input) if input == "Tom-ay-to, tom-aaaah-to." return "Whatever." elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input == "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." elsif input == "WHAT THE HELL WERE YOU THINKING?" return "Whoa, chill out!" elsif input == "1, 2, 3 GO!" return "Whoa, chill out!" elsif input == "1, 2, 3" return "Whatever." elsif input == "4?" return "Sure." elsif input == "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" return "Whoa, chill out!" elsif input == "I HATE YOU" return "Whoa, chill out!" elsif input == "Ending with ? means a question." return "Whatever." elsif input == "Wait! Hang on. Are you going to be OK?" return "Sure." elsif input == "" return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == " " return "Fine. Be that way!" elsif input == "Does this cryogenic chamber make me look fat?\nno" return "Whatever." end end end
  17. Iteration #3 class Bob def hey(input) case input when "Tom-ay-to,

    tom-aaaah-to." "Whatever." when "WATCH OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?"
  18. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  19. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  20. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  21. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  22. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  23. Iteration #3 case input when "Tom-ay-to, tom-aaaah-to." "Whatever." when "WATCH

    OUT!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?" "Sure." when "You are, what, like 15?" "Sure." when "Let's go make out behind the gym!" "Whatever." when "It's OK if you don't want to go to the DMV." "Whatever." when "WHAT THE HELL WERE YOU THINKING?" "Whoa, chill out!" when "1, 2, 3 GO!" "Whoa, chill out!" when "1, 2, 3" "Whatever." when "4?" "Sure." when "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?\nno" "Whatever." when "I HATE YOU" "Whoa, chill out!" when "Ending with ? means a question." "Whatever." when "Wait! Hang on. Are you going to be OK?" "Sure." when "" "Fine. Be that way!" when " " "Fine. Be that way!" when " " "Fine. Be that way!" end
  24. Iteration #3 class Bob def hey(input) case input when "Tom-ay-to,

    tom-aaaah-to.", "Let's go make out behind the gym! "Whatever." when "WATCH OUT!", "WHAT THE HELL WERE YOU THINKING?", "1, 2, 3 GO! "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?", "You are, wha "Sure." when "", " ", " " "Fine. Be that way!" end end end
  25. Iteration #4 class Bob def hey(input) case input when "Tom-ay-to,

    tom-aaaah-to.", "Let's go make out behind the gym! "Whatever." when "WATCH OUT!", "WHAT THE HELL WERE YOU THINKING?", "1, 2, 3 GO! "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?", "You are, wha "Sure." when "", " ", " " "Fine. Be that way!" end end end
  26. Iteration #4 class Bob def hey(input) case input when "Tom-ay-to,

    tom-aaaah-to.", "Let's go make out behind the gym!", "It's OK if you don't want to go to the DMV.", "1, 2, 3", "Does this cryogenic chamber make me look fat?\nno", "Ending with ? means a question." "Whatever." when "WATCH OUT!", "WHAT THE HELL WERE YOU THINKING?", "1, 2, 3 GO!", "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!", "I HATE YOU" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?", "You are, what, like 15?", "4?", "Wait! Hang on. Are you going to be OK?" "Sure." when "", " ", " " "Fine. Be that way!" end end end
  27. Iteration #4 "Whoa, chill out!" when "Does this cryogenic chamber

    make me look fat?", "You are, what, like 15?", "4?", "Wait! Hang on. Are you going to be OK?" "Sure." when "",
  28. Iteration #4 "Whatever." when "WATCH OUT!", "WHAT THE HELL WERE

    YOU THINKING?", "1, 2, 3 GO!", "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!", "I HATE YOU" "Whoa, chill out!" when "Does this cryogenic chamber make me look fat?",
  29. Iteration #4 case input when "Tom-ay-to, tom-aaaah-to.", "Let's go make

    out behind the gym!", "It's OK if you don't want to go to the DMV.", "1, 2, 3", "Does this cryogenic chamber make me look fat?\nno", "Ending with ? means a question." "Whatever." when "WATCH OUT!",
  30. Iteration #5 class Bob def hey(input) return "Whoa, chill out!"

    if input =~ /\A[\dA-Z\s\W]+\z/ and input =~ /[A-Z]/ return "Sure." if input.split("").last == "?" return "Fine. Be that way!" if input.strip == "" "Whatever." end end
  31. Iteration #5 class Bob def hey(input) return "Whoa, chill out!"

    if input =~ /\A[\dA-Z\s\W]+\z/ and input =~ /[A-Z]/ return "Sure." if input.split("").last == "?" return "Fine. Be that way!" if input.strip == "" "Whatever." end end
  32. Iteration #5 class Bob def hey(input) return "Whoa, chill out!"

    if input =~ /\A[\dA-Z\s\W]+\z/ and input =~ /[A-Z]/ return "Sure." if input.split("").last == "?" return "Fine. Be that way!" if input.strip == "" "Whatever." end end
  33. Iteration #5 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase and input != input.downcase return "Sure." if input.split("").last == "?" return "Fine. Be that way!" if input.strip == "" "Whatever." end end
  34. Iteration #5 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase and input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip == "" "Whatever." end end
  35. Iteration #6 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase and input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip.empty? "Whatever." end end
  36. Iteration #6 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase and input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip.empty? "Whatever." end end
  37. Iteration #6 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase && input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip.empty? "Whatever." end end
  38. Iteration #7 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase && input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip.empty? "Whatever." end end
  39. Iteration #7 class Bob def hey(input) return "Whoa, chill out!"

    if input == input.upcase && input != input.downcase return "Sure." if input.end_with?("?") return "Fine. Be that way!" if input.strip.empty? "Whatever." end end
  40. Iteration #7 class Bob def hey(input) case when input ==

    input.upcase && input != input.downcase "Whoa, chill out!" when input.end_with?("?") "Sure." when input.strip.empty? "Fine. Be that way!" else "Whatever." end end end
  41. Iteration #8 class Bob def hey(input) case when input ==

    input.upcase && input != input.downcase "Whoa, chill out!" when input.end_with?("?") "Sure." when input.strip.empty? "Fine. Be that way!" else "Whatever." end end end
  42. Iteration #8 class Bob def hey(input) @input = input case

    when all_caps? then "Whoa, chill out!" when question? then "Sure." when empty? then "Fine. Be that way!" else "Whatever." end end def empty? @input.strip.empty? end def question? @input.end_with?("?") end def all_caps? @input == @input.upcase && @input != @input.downcase end end
  43. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  44. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  45. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  46. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  47. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  48. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  49. Iteration #9 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  50. Iteration #10 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  51. Iteration #10 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private def silence? @input.strip.empty? end def question? @input.end_with?("?") end def shout? @input == @input.upcase && @input != @input.downcase end end
  52. Iteration #10 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private attr_reader :input def silence? input.strip.empty? end def question? input.end_with?("?") end def shout? input == input.upcase && input != input.downcase end end
  53. Iteration #11 class Bob def hey(input) @input = input case

    when shout? then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private attr_reader :input def silence? input.strip.empty? end def question? input.end_with?("?") end def shout? input == input.upcase && input != input.downcase end end
  54. private attr_reader :input def silence? input.strip.empty? end ... Iteration #11

    private def silence? ->(s) { s.strip.empty? } end ...
  55. Iteration #12 class Bob def hey(input) case input when shout?

    then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private def silence? ->(s) { s.strip.empty? } end def question? ->(s) { s.end_with?("?") } end def shout? ->(s) { s == s.upcase && s != s.downcase } end end
  56. special case case age when ->(i) { i < 13

    } then "kiddo" when ->(i) { i % 25 == 0 } then "quarter" when ->(i) { i % 10 == 0 } then "decade" end
  57. Iteration #12 class Bob def hey(input) case input when shout?

    then "Whoa, chill out!" when question? then "Sure." when silence? then "Fine. Be that way!" else "Whatever." end end private def silence? ->(s) { s.strip.empty? } end def question? ->(s) { s.end_with?("?") } end def shout? ->(s) { s == s.upcase && s != s.downcase } end end
  58. private def silence? ->(s) { s.strip.empty? } end def question?

    ->(s) { s.end_with?("?") } end def shout? ->(s) { s == s.upcase && s != s.downcase } end Iteration #12
  59. private def silence? ->(s) { s.strip.empty? } end def question?

    ->(s) { s.end_with?("?") } end def shout? ->(s) { s == s.upcase && s != s.downcase } end Iteration #12 private def silence?(s) s.strip.empty? end def question?(s) s.end_with?("?") end def shout?(s) s == s.upcase && s != s.downcase end
  60. Iteration #13 class Bob def hey(input) case when shout?(input) then

    "Whoa, chill out!" when question?(input) then "Sure." when silence?(input) then "Fine. Be that way!" else "Whatever." end end private def silence?(s) s.strip.empty? end def question?(s) s.end_with?("?") end def shout?(s) s == s.upcase && s != s.downcase end end
  61. Iteration #13 class Bob def hey(input) case when shout?(input) then

    "Whoa, chill out!" when question?(input) then "Sure." when silence?(input) then "Fine. Be that way!" else "Whatever." end end private def silence?(s) s.strip.empty? end def question?(s) s.end_with?("?") end def shout?(s) s == s.upcase && s != s.downcase end end
  62. Iteration #13 class Bob def hey(input) case when shout?(input) then

    "Whoa, chill out!" when question?(input) then "Sure." when silence?(input) then "Fine. Be that way!" else "Whatever." end end private def silence?(s) s.strip.empty? end def question?(s) s.end_with?("?") end def shout?(s) s == s.upcase && s != s.downcase end end
  63. Iteration #13 class Bob def hey(input) case when shout?(input) then

    "Whoa, chill out!" when question?(input) then "Sure." when silence?(input) then "Fine. Be that way!" else "Whatever." end end private def silence?(s) s.strip.empty? end def question?(s) s.end_with?("?") end def shout?(s) s == s.upcase && s != s.downcase end end
  64. Iteration #13 class Bob def hey(input) case when input.shout? then

    "Whoa, chill out!" when input.question? then "Sure." when input.silence? then "Fine. Be that way!" else "Whatever." end end end class String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  65. Iteration #14 class Bob def hey(input) case when input.shout? then

    "Whoa, chill out!" when input.question? then "Sure." when input.silence? then "Fine. Be that way!" else "Whatever." end end end class String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  66. Iteration #14 class Bob def hey(input) case when input.shout? then

    "Whoa, chill out!" when input.question? then "Sure." when input.silence? then "Fine. Be that way!" else "Whatever." end end end class String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  67. Iteration #14 class Bob def hey(input) input = Input.new(input) case

    when input.shout? then "Whoa, chill out!" when input.question? then "Sure." when input.silence? then "Fine. Be that way!" else "Whatever." end end end class Input < String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  68. Iteration #15 class Bob def hey(input) input = Input.new(input) case

    when input.shout? then "Whoa, chill out!" when input.question? then "Sure." when input.silence? then "Fine. Be that way!" else "Whatever." end end end class Input < String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  69. beware! s.sparkle # => **;* unicorn **;** s.upcase # =>

    UNICORN s << 's' # => "unicorns" s.sparkle # => **;* unicorns **;**
  70. Iteration #15 class Bob # ... end class Input <

    String def silence? strip.empty? end def question? end_with?("?") end def shout? self == upcase && self != downcase end end
  71. Iteration #15 class Bob # ... end class Input attr_reader

    :input def initialize(input) @input = input end def silence? input.strip.empty? end def question? input.end_with?("?") end def shout? input == input.upcase && input != input.downcase end end
  72. Iteration #16 class Bob def hey(input) input = Input.new(input) case

    # ... end end end class Input attr_reader :input def initialize(input) @input = input end def silence? input.strip.empty? end def question? input.end_with?("?") end def shout? input == input.upcase && input != input.downcase end end
  73. Iteration #16 class Bob def hey(input) input = Input.new(input) case

    # ... end end end class Input attr_reader :input def initialize(input) @input = input end def silence? input.strip.empty? end def question? input.end_with?("?") end def shout? input == input.upcase && input != input.downcase end end
  74. Iteration #16 class Bob def hey(remark) remark = Remark.new(remark) case

    # ... end end end class Remark attr_reader :remark def initialize(remark) @remark = remark end def silence? remark.strip.empty? end def question? remark.end_with?("?") end def shout? remark == remark.upcase && remark != remark.downcase end end
  75. Iteration #16 class Bob def hey(remark) remark = Remark.new(remark) case

    # ... end end end class Remark attr_reader :remark def initialize(remark) @remark = remark end def silence? remark.strip.empty? end def question? remark.end_with?("?") end def shout? remark == remark.upcase && remark != remark.downcase end end
  76. echoes var srcData = data; if (data.data && data.data.data) {

    data = data.data.data; } else if (data.data) { data = data.data; } if (!data) { return; }
  77. Final Solution class Bob def hey(text) remark = Remark.new(text) case

    # ... end end end class Remark attr_reader :text def initialize(text) @text = text end def silence? text.strip.empty? end def question? text.end_with?("?") end def shout? text == text.upcase && text != text.downcase end end case when remark.shout? then "Whoa, chill out!" when remark.question? then "Sure." when remark.silence? then "Fine. Be that way!" else "Whatever." end
  78. class Bob def hey (input ) if input=="Tom-ay-to, tom-aaaah-to." return"Whatever."

    elsif input == "WATCH OUT!" return "Whoa, chill out!" elsif input == "Does this cryogenic chamber make me look fat?" return "Sure." elsif input== "You are, what, like 15?" return "Sure." elsif input == "Let's go make out behind the gym!" return "Whatever." elsif input == "It's OK if you don't want to go to the DMV." return "Whatever." Initial Solution
  79. credits Simple Made Easy http://www.infoq.com/presentations/Simple-Made-Easy Rich Hickey 5 elements of

    Effective Thinking Michael Starbird, Edward Burger Smalltalk Implementation Patterns Kent Beck Mark by Mark http://vimeo.com/79530470 Sarah Gray