SlideShare ist ein Scribd-Unternehmen logo
1 von 12
• Presentation is available online at
– http://www.slideshare.net/jasonjnoble/tdd_rspec_palindrome
Test Driven Design
to learn Recursion and Palindromes
Jason Noble
instructor@jasonnoble.org
Test Driven Design
• TDD is a software development practice that
relies on the repetition of a very short
development cycle
– Write a failing test that defines a desired
improvement or new function
– Write the minimum code possible to make the
test pass
– Refactor the code to acceptable standards
Red Green Refactor
• Write a failing test (Red)
• Make the test pass (Green)
• Refactor tests or code (NOT both!)
Why use TDD?
• Helps you break problems down into small
manageable tasks
• Writing tests takes the fear out of
programming
• Writing tests helps you communicate what
your code SHOULD do/accomplish
Let's Talk about Recursion
• "In order to understand recursion, you must
first understand recursion." – Anonymous
• Let's ask Google
What is recursion?
What is recursion?
• Recursion is simply:
– A simple base case (or base cases)
– A set of rules that reduce all other cases towards a
known base case
• Example:
– Your parents are your ancestors (base case)
– The ancestors of your ancestors are also your
ancestors (recursion step)
Another example
• Factorial
– 1! equals 1 (Base case)
– For any number n greater than 1, the factorial of
that number is simply n * n – 1
– Factorial of 2 is 2 * 1! = 2 * 1 (base case) = 2
– Factorial of 3 is 3 * 1! = 3 * 2 = 6
– Factorial of 4 is 4 * 3! = 4 * 6 = 24
– Factorial of 5 is 5 * 4! = 5 * 24 = 120
Palindrome
• A palindrome is defined as "A
word, phrase, number or other sequence of
symbols or elements, whose meaning may be
interpreted the same way in either forward or
reverse direction".
• dad == dad.reverse
• 10022001
• radar
Let's code it!
• git clone
git@github.com:jasonnoble/tdd_rspec_palind
rome.git
• What's in this repo?
Palindrome recursive definition
• A given string is a palindrome if the string read
forward is the same as the string read
backwards
• Is an empty string a palindrome?
• Is a single character a palindrome?

Weitere ähnliche Inhalte

Mehr von Jason Noble

Dash of ajax
Dash of ajaxDash of ajax
Dash of ajaxJason Noble
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery IntroJason Noble
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaJason Noble
 
Google apps
Google appsGoogle apps
Google appsJason Noble
 
Smarter cart
Smarter cartSmarter cart
Smarter cartJason Noble
 
Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01Jason Noble
 
Catalog display
Catalog displayCatalog display
Catalog displayJason Noble
 
Validation unit testing
Validation unit testingValidation unit testing
Validation unit testingJason Noble
 
Creating the application
Creating the applicationCreating the application
Creating the applicationJason Noble
 
Capistrano
CapistranoCapistrano
CapistranoJason Noble
 
Atlanta Pm Git 101
Atlanta Pm Git 101Atlanta Pm Git 101
Atlanta Pm Git 101Jason Noble
 
Regex Intro
Regex IntroRegex Intro
Regex IntroJason Noble
 

Mehr von Jason Noble (15)

Rspec 101
Rspec 101Rspec 101
Rspec 101
 
Dash of ajax
Dash of ajaxDash of ajax
Dash of ajax
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery Intro
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Google apps
Google appsGoogle apps
Google apps
 
Smarter cart
Smarter cartSmarter cart
Smarter cart
 
Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01
 
Catalog display
Catalog displayCatalog display
Catalog display
 
Validation unit testing
Validation unit testingValidation unit testing
Validation unit testing
 
Creating the application
Creating the applicationCreating the application
Creating the application
 
Capistrano
CapistranoCapistrano
Capistrano
 
Atlanta Pm Git 101
Atlanta Pm Git 101Atlanta Pm Git 101
Atlanta Pm Git 101
 
Regex Intro
Regex IntroRegex Intro
Regex Intro
 
Git101
Git101Git101
Git101
 
Git102
Git102Git102
Git102
 

KĂĽrzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 

KĂĽrzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

Tdd rspec palindrome

  • 1. • Presentation is available online at – http://www.slideshare.net/jasonjnoble/tdd_rspec_palindrome
  • 2. Test Driven Design to learn Recursion and Palindromes Jason Noble instructor@jasonnoble.org
  • 3. Test Driven Design • TDD is a software development practice that relies on the repetition of a very short development cycle – Write a failing test that defines a desired improvement or new function – Write the minimum code possible to make the test pass – Refactor the code to acceptable standards
  • 4. Red Green Refactor • Write a failing test (Red) • Make the test pass (Green) • Refactor tests or code (NOT both!)
  • 5. Why use TDD? • Helps you break problems down into small manageable tasks • Writing tests takes the fear out of programming • Writing tests helps you communicate what your code SHOULD do/accomplish
  • 6. Let's Talk about Recursion • "In order to understand recursion, you must first understand recursion." – Anonymous • Let's ask Google
  • 8. What is recursion? • Recursion is simply: – A simple base case (or base cases) – A set of rules that reduce all other cases towards a known base case • Example: – Your parents are your ancestors (base case) – The ancestors of your ancestors are also your ancestors (recursion step)
  • 9. Another example • Factorial – 1! equals 1 (Base case) – For any number n greater than 1, the factorial of that number is simply n * n – 1 – Factorial of 2 is 2 * 1! = 2 * 1 (base case) = 2 – Factorial of 3 is 3 * 1! = 3 * 2 = 6 – Factorial of 4 is 4 * 3! = 4 * 6 = 24 – Factorial of 5 is 5 * 4! = 5 * 24 = 120
  • 10. Palindrome • A palindrome is defined as "A word, phrase, number or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction". • dad == dad.reverse • 10022001 • radar
  • 11. Let's code it! • git clone git@github.com:jasonnoble/tdd_rspec_palind rome.git • What's in this repo?
  • 12. Palindrome recursive definition • A given string is a palindrome if the string read forward is the same as the string read backwards • Is an empty string a palindrome? • Is a single character a palindrome?