SlideShare una empresa de Scribd logo
1 de 70
The Origamist’s Ruby
折り紙作家のルビー
@halogenandtoast
Matthew "Goose" Mongeau
https://github.com/halogenandtoast
@halogenandtoast
Matthew "Goose" Mongeau
https://github.com/halogenandtoast
グース
@halogenandtoast
Matthew "Goose" Mongeau
https://github.com/halogenandtoast
What is this talk
about?
"Not all code needs to
be a factory, some of it
can just be origami."
- _why
"A programmer who subconsciously
views himself as an artist will enjoy
what he does and will do it better."
- Donald Knuth
What is Origami?
The art of
folding paper.
Demonstration
O o
Imagination Required
ガオー
Origami is Art
Origami is Art
It’s beautiful.
Origami is Art
It’s beautiful.
It’s creative.
It’s beautiful.
It’s creative.
It’s expressive.
Origami is Art
What is
Programming?
The art of
writing code.
Code is Art
Code is Art
It’s beautiful.
Code is Art
It’s beautiful.
It’s creative.
Code is Art
It’s beautiful.
It’s creative.
It’s expressive.
How do you write
beautiful code?
Simplicity
単純
Code should be simple
to understand.
def play
puts "Welcome to the guessing game."
3.times do
guess = get_guess
if won? guess
@won = true
puts "You win!"
break
else
puts "Wrong!"
end
end
if !@won
puts "You lost.The actual number is #{@actual_number}."
end
end
def play
puts "Welcome to the guessing game."
3.times do
guess = get_guess
if won? guess
@won = true
puts "You win!"
break
else
puts "Wrong!"
end
end
if !@won
puts "You lost.The actual number is #{@actual_number}."
end
end
def play
print_header
play_rounds
print_results
end
def play
puts "Welcome to the guessing game."
play_rounds
print_results
end
def play
print_header
play_rounds
print_results
end
Complexity
複雑
How do you balance
simplicity and complexity?
def play_rounds
round_count.times do
if correct_guess? get_guess
@won = true
break
else
puts "Wrong!"
end
end
end
def play_rounds
@won = round_count.times.detect { play_round }
end
def play_round
if correct_guess? get_guess
true
else
puts "Wrong!"
end
end
Constraints
規制
Origami’s Constraints
Origami’s Constraints
Must use a single sheet of paper.
Origami’s Constraints
Must 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 Metz
Methods can be no longer than 5 lines.
Code Constraints*
*Borrowed from Sandi Metz
Methods can be no longer than 5 lines.
Classes can be no longer than 100 lines.
Code Constraints*
*Borrowed from Sandi Metz
Methods can be no longer than 5 lines.
Classes can be no longer than 100 lines.
Methods cannot take more than 4 arguments.
def play
puts "Welcome to the guessing game."
3.times do
guess = get_guess
if won? guess
@won = true
puts "You win!"
break
else
puts "Wrong!"
end
end
if !@won
puts "You lost.The actual number is #{@actual_number}."
end
end
def play
print_header
play_rounds
print_results
end
def play_rounds
round_count.times do
if correct_guess? get_guess
@won = true
break
else
puts "Wrong!"
end
end
end
def play_rounds
@won = round_count.times.detect { play_round }
end
def play_round
if correct_guess? get_guess
true
else
puts "Wrong!"
end
end
http://www.flickr.com/photos/ardonik/3954691105/sizes/l/in/photostream/
Breaking the Rules
違反
"Learn the rules like a
pro, so you can break
them like an artist."
- Pablo Picasso
def play_round
if correct_guess? get_guess
true
else
puts "Wrong!"
end
end
def play_round
if correct_guess? get_guess
puts "Correct"
true
else
puts "Wrong!"
false
end
end
def play_round
if correct_guess? get_guess
correct_guess
else
incorrect_guess
end
end
def incorrect_guess
puts "Wrong!"
false
end
def correct_guess
puts "Correct"
false
end
class Guess
def initialize actual_number
@actual_number = actual_number
@guess = get_guess
end
def status
if correct?
"Correct"
else
"Incorrect"
end
end
def correct?
guess == actual_number
end
private
attr_reader :guess, :actual_number
def get_guess
print "What is your guess: "
gets.to_i
end
end
class Guess
def initialize actual_number
@actual_number = actual_number
@guess = get_guess
end
def status
if correct?
"Correct"
else
"Incorrect"
end
end
def correct?
guess == actual_number
end
private
attr_reader :guess, :actual_number
def get_guess
print "What is your guess: "
gets.to_i
end
end
def play_round
guess = Guess.new(actual_number)
puts guess.display_status
guess.correct?
end
How to be an artist
Be inspired by others
Surround yourself with
talented artists
Surround yourself with
talented artists
Use well known
techniques
Use well known
techniques
Measure improvement
Have feelings
Know when to break
the rules
Have fun.
RUBYKAIGI
$20 off first month
Prime
learn.thoughtbot.com/prime
Questions?

Más contenido relacionado

Destacado

Network simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linuxNetwork simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linuxPratik Joshi
 
3 Pillars of Universal Design
3 Pillars of Universal Design3 Pillars of Universal Design
3 Pillars of Universal Designcentralmath
 
Performance comparision 1307.4129
Performance comparision 1307.4129Performance comparision 1307.4129
Performance comparision 1307.4129Pratik Joshi
 
POWER INTERACTIVO DE MATEMATICA
POWER INTERACTIVO DE MATEMATICAPOWER INTERACTIVO DE MATEMATICA
POWER INTERACTIVO DE MATEMATICAmarita1277
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercisePratik Joshi
 

Destacado (8)

Network simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linuxNetwork simulator 2 a simulation tool for linux
Network simulator 2 a simulation tool for linux
 
First One
First OneFirst One
First One
 
Ns doc
Ns docNs doc
Ns doc
 
3 Pillars of Universal Design
3 Pillars of Universal Design3 Pillars of Universal Design
3 Pillars of Universal Design
 
Performance comparision 1307.4129
Performance comparision 1307.4129Performance comparision 1307.4129
Performance comparision 1307.4129
 
POWER INTERACTIVO DE MATEMATICA
POWER INTERACTIVO DE MATEMATICAPOWER INTERACTIVO DE MATEMATICA
POWER INTERACTIVO DE MATEMATICA
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercise
 
Cygwin ug-net
Cygwin ug-netCygwin ug-net
Cygwin ug-net
 

Último

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Último (20)

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Origamist's ruby