Upcoming SlideShare
×

# Origamist's ruby

348 views

Published on

My talk from 2013 Ruby Kaigi.

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• http://vimeo.com/70184420

Are you sure you want to  Yes  No
• Be the first to like this

Views
Total views
348
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
0
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
28. 28. def playputs "Welcome to the guessing game."play_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
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.ﬂickr.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 ﬁrst monthPrimelearn.thoughtbot.com/prime
66. 66. Questions?