The Origamist’s Ruby折り紙作家のルビー
@halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoast
@halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoastグース
@halogenandtoastMatthew "Goose" Mongeauhttps://github.com/halogenandtoast
What is this talkabout?
"Not all code needs tobe a factory, some of itcan just be origami."- _why
"A programmer who subconsciouslyviews himself as an artist will enjoywhat he does and will do it better."- Donald Knuth
What is Origami?
The art offolding paper.
Demonstration
O oImagination Requiredガオー
Origami is Art
Origami is ArtIt’s beautiful.
Origami is ArtIt’s beautiful.It’s creative.
It’s beautiful.It’s creative.It’s expressive.Origami is Art
What isProgramming?
The art ofwriting code.
Code is Art
Code is ArtIt’s beautiful.
Code is ArtIt’s beautiful.It’s creative.
Code is ArtIt’s beautiful.It’s creative.It’s expressive.
How do you writebeautiful code?
Simplicity単純
Code should be simpleto understand.
def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseput...
def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseput...
def playprint_headerplay_roundsprint_resultsend
def playputs "Welcome to the guessing game."play_roundsprint_resultsend
def playprint_headerplay_roundsprint_resultsend
Complexity複雑
How do you balancesimplicity and complexity?
def play_roundsround_count.times doif correct_guess? get_guess@won = truebreakelseputs "Wrong!"endendend
def play_rounds@won = round_count.times.detect { play_round }enddef play_roundif correct_guess? get_guesstrueelseputs "Wro...
Constraints規制
Origami’s Constraints
Origami’s ConstraintsMust use a single sheet of paper.
Origami’s ConstraintsMust use a single sheet of paper.Must be in the shape of a square.
Must use a single sheet of paper.Must be in the shape of a square.Must not cut the square.Origami’s Constraints
Code Constraints
Code Constraints**Borrowed from Sandi Metz
Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.
Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.Classes can be no longer than 100 lines.
Code Constraints**Borrowed from Sandi MetzMethods can be no longer than 5 lines.Classes can be no longer than 100 lines.Me...
def playputs "Welcome to the guessing game."3.times doguess = get_guessif won? guess@won = trueputs "You win!"breakelseput...
def playprint_headerplay_roundsprint_resultsend
def play_roundsround_count.times doif correct_guess? get_guess@won = truebreakelseputs "Wrong!"endendend
def play_rounds@won = round_count.times.detect { play_round }enddef play_roundif correct_guess? get_guesstrueelseputs "Wro...
http://www.flickr.com/photos/ardonik/3954691105/sizes/l/in/photostream/Breaking the Rules違反
"Learn the rules like apro, so you can breakthem like an artist."- Pablo Picasso
def play_roundif correct_guess? get_guesstrueelseputs "Wrong!"endend
def play_roundif correct_guess? get_guessputs "Correct"trueelseputs "Wrong!"falseendend
def play_roundif correct_guess? get_guesscorrect_guesselseincorrect_guessendenddef incorrect_guessputs "Wrong!"falseenddef...
class Guessdef initialize actual_number@actual_number = actual_number@guess = get_guessenddef statusif correct?"Correct"el...
class Guessdef initialize actual_number@actual_number = actual_number@guess = get_guessenddef statusif correct?"Correct"el...
How to be an artist
Be inspired by others
Surround yourself withtalented artists
Surround yourself withtalented artists
Use well knowntechniques
Use well knowntechniques
Measure improvement
Have feelings
Know when to breakthe rules
Have fun.
RUBYKAIGI$20 off first monthPrimelearn.thoughtbot.com/prime
Questions?
Origamist's ruby
Origamist's ruby
Origamist's ruby
Origamist's ruby
Upcoming SlideShare
Loading in …5
×

Origamist's ruby

329 views
272 views

Published on

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
329
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Origamist's ruby

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

×