Your SlideShare is downloading. ×

Origamist's ruby

187
views

Published on

My talk from 2013 Ruby Kaigi.

My talk from 2013 Ruby Kaigi.

Published in: Technology

1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
187
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
1
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. The Origamist’s Ruby折り紙作家のルビー
  • 2. @halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoast
  • 3. @halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoastグース
  • 4. @halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoast
  • 5. What is this talkabout?
  • 6. "Not all code needs tobe a factory, some of itcan just be origami."- _why
  • 7. "A programmer who subconsciouslyviews himself as an artist will enjoywhat he does and will do it better."- Donald Knuth
  • 8. What is Origami?
  • 9. The art offolding paper.
  • 10. Demonstration
  • 11. O oImagination Requiredガオー
  • 12. Origami is Art
  • 13. Origami is ArtIt’s beautiful.
  • 14. Origami is ArtIt’s beautiful.It’s creative.
  • 15. It’s beautiful.It’s creative.It’s expressive.Origami is Art
  • 16. What isProgramming?
  • 17. The art ofwriting code.
  • 18. Code is Art
  • 19. Code is ArtIt’s beautiful.
  • 20. Code is ArtIt’s beautiful.It’s creative.
  • 21. Code is ArtIt’s beautiful.It’s creative.It’s expressive.
  • 22. How do you writebeautiful code?
  • 23. Simplicity単純
  • 24. Code should be simpleto understand.
  • 25. def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseputs "Wrong!"endendif !@wonputs "You lost.The actual number is #{@actual_number}."endend
  • 26. def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseputs "Wrong!"endendif !@wonputs "You lost.The actual number is #{@actual_number}."endend
  • 27. def playprint_headerplay_roundsprint_resultsend
  • 28. def playputs "Welcome to the guessing game."play_roundsprint_resultsend
  • 29. def playprint_headerplay_roundsprint_resultsend
  • 30. Complexity複雑
  • 31. How do you balancesimplicity and complexity?
  • 32. def play_roundsround_count.times doif correct_guess? get_guess@won = truebreakelseputs "Wrong!"endendend
  • 33. def play_rounds@won = round_count.times.detect { play_round }enddef play_roundif correct_guess? get_guesstrueelseputs "Wrong!"endend
  • 34. Constraints規制
  • 35. Origami’s Constraints
  • 36. Origami’s ConstraintsMust use a single sheet of paper.
  • 37. Origami’s ConstraintsMust use a single sheet of paper.Must be in the shape of a square.
  • 38. Must use a single sheet of paper.Must be in the shape of a square.Must not cut the square.Origami’s Constraints
  • 39. Code Constraints
  • 40. Code Constraints**Borrowed from Sandi Metz
  • 41. Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.
  • 42. Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.Classes can be no longer than 100 lines.
  • 43. Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.Classes can be no longer than 100 lines.Methods cannot take more than 4 arguments.
  • 44. def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseputs "Wrong!"endendif !@wonputs "You lost.The actual number is #{@actual_number}."endend
  • 45. def playprint_headerplay_roundsprint_resultsend
  • 46. def play_roundsround_count.times doif correct_guess? get_guess@won = truebreakelseputs "Wrong!"endendend
  • 47. def play_rounds@won = round_count.times.detect { play_round }enddef play_roundif correct_guess? get_guesstrueelseputs "Wrong!"endend
  • 48. http://www.flickr.com/photos/ardonik/3954691105/sizes/l/in/photostream/Breaking the Rules違反
  • 49. "Learn the rules like apro, so you can breakthem like an artist."- Pablo Picasso
  • 50. def play_roundif correct_guess? get_guesstrueelseputs "Wrong!"endend
  • 51. def play_roundif correct_guess? get_guessputs "Correct"trueelseputs "Wrong!"falseendend
  • 52. def play_roundif correct_guess? get_guesscorrect_guesselseincorrect_guessendenddef incorrect_guessputs "Wrong!"falseenddef correct_guessputs "Correct"falseend
  • 53. class Guessdef initialize actual_number@actual_number = actual_number@guess = get_guessenddef statusif correct?"Correct"else"Incorrect"endenddef correct?guess == actual_numberendprivateattr_reader :guess, :actual_numberdef get_guessprint "What is your guess: "gets.to_iendend
  • 54. class Guessdef initialize actual_number@actual_number = actual_number@guess = get_guessenddef statusif correct?"Correct"else"Incorrect"endenddef correct?guess == actual_numberendprivateattr_reader :guess, :actual_numberdef get_guessprint "What is your guess: "gets.to_iendenddef play_roundguess = Guess.new(actual_number)puts guess.display_statusguess.correct?end
  • 55. How to be an artist
  • 56. Be inspired by others
  • 57. Surround yourself withtalented artists
  • 58. Surround yourself withtalented artists
  • 59. Use well knowntechniques
  • 60. Use well knowntechniques
  • 61. Measure improvement
  • 62. Have feelings
  • 63. Know when to breakthe rules
  • 64. Have fun.
  • 65. RUBYKAIGI$20 off first monthPrimelearn.thoughtbot.com/prime
  • 66. Questions?