Share
Embed
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
Transcript
231 slides
-
README Bob is a lackadaisical teenager. In conversation, his responses
are very limited. -
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. -
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 -
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 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 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 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 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 Iteration #1 -
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 -
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 -
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." -
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 -
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 -
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 -
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 -
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 -
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?" -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
Iteration #3 ic chamber make me look fat?\nno", "Ending with
? means a question." -
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 -
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 -
Iteration #4 "Sure." when "", " ", " " "Fine.
Be that way!" end end end -
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 "", -
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?", -
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!", -
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 -
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 -
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 -
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 -
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 -
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 -
boolean vs control flow if hungry? && thirsty? eat and
drink and be_merry! end -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
"ARE YOU CRAZY?" @input confusion ensues B A "ARE YOU
CRAZY?" C "You’re late." -
@input "You’re late." confusion ensues B A "ARE YOU CRAZY?"
C "You’re late." -
private attr_reader :input def silence? input.strip.empty? end ... Iteration #11
private def silence? ->(s) { s.strip.empty? } end ... -
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 -
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 -
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 -
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 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 -
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 -
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 -
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 -
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 -
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 -
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 -
String API #downcase #gsub #reverse #scan #squeeze #to_i ... #question?
#shout? #silence? -
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 -
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 -
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 -
Input API #downcase #gsub #reverse #scan #squeeze #to_i ... #question?
#shout? #silence? -
beware! s.sparkle # => **;* unicorn **;** s.upcase # =>
UNICORN s << 's' # => "unicorns" -
beware! s.sparkle # => **;* unicorn **;** s.upcase # =>
UNICORN s << 's' # => "unicorns" s.sparkle # => **;* unicorns **;** -
s1.sparkle # => **;* unicorn **;** s2.sparkle # => **;*
rainbow **;** beware! -
beware! s3.sparkle # => undefined method `sparkle' for "unicornrainbow":String (NoMethodError)
s3 = s1 + s2 # => "unicornrainbow" -
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 -
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 -
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 -
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 -
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 -
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 -
echoes var srcData = data; if (data.data && data.data.data) {
data = data.data.data; } else if (data.data) { data = data.data; } if (!data) { return; } -
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 -
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 -
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