Date post: | 06-May-2015 |
Category: |
Technology |
Upload: | sarah-allen |
View: | 605 times |
Download: | 0 times |
Ruby
Class
The Ruby Language
• Originally by Yukihiro "Matz" Matsumoto• “Ruby is designed for programmer
productivity and fun, following the principles of good user interface design. He stresses that systems design needs to emphasize human, rather than computer, needs.”
http://en.wikipedia.org/wiki/Ruby_(programming_language)#History
• Ruby 1.0 was released in 1996.
The Ruby Language
• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions
Ruby Implementations
• Ruby 1.8.x (MRI)• Ruby 1.9.x (YARV)• Rubinius• JRuby• MacRuby, HotCocoa• IronRuby for .NET
What you will learn
• Ruby– Language concepts & tools– Language syntax– Some standard library classes & gems– Common patterns
Book
• The Well-Grounded RubyistCovering Ruby 1.9
David A. Black
How you will learn
• Exploration: experiment, play• Test-Driven Development (TDD)– Initially as a learning methodology– Later as a development methodology
• Ask questions• Learn to find your own answers• Read
• Plus whatever works best for you
Class Structure
• Talk• Live Coding Demonstrations• In-class coding• Coding at home (or in social groups)• Google Group
Other Resources
• SF Ruby Meetup• RailsBridge
See Last page of hand-out for more
Class Topics
Class 1 Introduction to RubyTest First Teaching Introduction to RSpec and Git
Class 2 Conditionals, Iterators (Hashes & Arrays) & Blocks
Class 3 Strings, Regex and Web Requests
Class 4 Files and Enumerables
Class 5 Performance
Class 6 Memory footprint, Building a gem
Ruby Language Overview
• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions
Lets get started
• IRB: InteractiveRuBy>> 4>> 4 + 4
Everything is an object
“test”.upcase“test”.class“test”.methods
Everything evaluates to something
2 + 2(2+2).zero?
Methods are Messages
thing.do(4)thing.do 4thing.send “do”, 4
Operators are Methods
thing.do 4thing.do(4)thing.send “do”, 4
1 + 21.+(2)1.send "+", 2
Write your first Ruby class
Test-First Learning
• Similar methodology to TDDwith a different purpose and workflow
• Teacher writes the test• Student implements the code
Test-Driven Development
• Design• Focus / Project Management• Documentation / Collaboration• Creation of Tests
Moving to TDD
• Build tests before refactoring or upgrading• Test-drive bug fixes• Write tests for anything you worry about• Continuous Integration is essential• Remove unused (untested) code
RED – GREEN – REFACTOR
1. Write the test2. Watch it fail3. Make it pass4. Make the code good, make sure it still passes
Unit Test Frameworks
• Test::Unit• Shoulda• Rspec
http://github.com/ultrasaurus/test-framework-comparison
Integration Test Frameworks
• Cucumber• Webrat• Selenium• And more…
Rspec
• Describe the feature• Verify expectation
Demonstration