+ All Categories
Home > Technology > Ruby Class 1

Ruby Class 1

Date post: 06-May-2015
Category:
Upload: sarah-allen
View: 605 times
Download: 0 times
Share this document with a friend
Description:
The slides from the first Ruby Class
25
Ruby Class
Transcript
Page 1: Ruby Class 1

Ruby

Class

Page 2: Ruby Class 1

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.

Page 3: Ruby Class 1

The Ruby Language

• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions

Page 4: Ruby Class 1

Ruby Implementations

• Ruby 1.8.x (MRI)• Ruby 1.9.x (YARV)• Rubinius• JRuby• MacRuby, HotCocoa• IronRuby for .NET

Page 5: Ruby Class 1

What you will learn

• Ruby– Language concepts & tools– Language syntax– Some standard library classes & gems– Common patterns

Page 6: Ruby Class 1

Book

• The Well-Grounded RubyistCovering Ruby 1.9

David A. Black

Page 7: Ruby Class 1

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

Page 8: Ruby Class 1

Class Structure

• Talk• Live Coding Demonstrations• In-class coding• Coding at home (or in social groups)• Google Group

Page 9: Ruby Class 1

Other Resources

• SF Ruby Meetup• RailsBridge

See Last page of hand-out for more

Page 10: Ruby Class 1

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

Page 11: Ruby Class 1

Ruby Language Overview

• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions

Page 12: Ruby Class 1

Lets get started

• IRB: InteractiveRuBy>> 4>> 4 + 4

Page 13: Ruby Class 1

Everything is an object

“test”.upcase“test”.class“test”.methods

Page 14: Ruby Class 1

Everything evaluates to something

2 + 2(2+2).zero?

Page 15: Ruby Class 1

Methods are Messages

thing.do(4)thing.do 4thing.send “do”, 4

Page 16: Ruby Class 1

Operators are Methods

thing.do 4thing.do(4)thing.send “do”, 4

1 + 21.+(2)1.send "+", 2

Page 17: Ruby Class 1

Write your first Ruby class

Page 18: Ruby Class 1

Test-First Learning

• Similar methodology to TDDwith a different purpose and workflow

• Teacher writes the test• Student implements the code

Page 19: Ruby Class 1

Test-Driven Development

• Design• Focus / Project Management• Documentation / Collaboration• Creation of Tests

Page 20: Ruby Class 1

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

Page 21: Ruby Class 1

RED – GREEN – REFACTOR

1. Write the test2. Watch it fail3. Make it pass4. Make the code good, make sure it still passes

Page 22: Ruby Class 1

Unit Test Frameworks

• Test::Unit• Shoulda• Rspec

http://github.com/ultrasaurus/test-framework-comparison

Page 23: Ruby Class 1

Integration Test Frameworks

• Cucumber• Webrat• Selenium• And more…

Page 24: Ruby Class 1

Rspec

• Describe the feature• Verify expectation

Page 25: Ruby Class 1

Demonstration


Recommended