Code & Supply #StarterSeries
Why?
Job Growth
Software development jobs will grow 32% through
2020.
Pays well
$93,350 median salary (2012)
Fun
Creative outlet
Other reasons? This presentation
Me
Professional Rails Dev - 5 years
Professional Software - 7 years
@justinxreese @codeandsupply @builderworksco
Starting out
Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results
Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results
Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results
Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results
What is a
program?
Basically: A file that can be
executed
More typically: a collection of
files that can be executed
How does
a program
run?
Think of it like “opening a
file with Ruby”
Code ProgramEditorEnvironment Results
Different Kinds of Programming
- Web
- Ruby on Rails, JavaScript, Python
- Native
- iOS (Objective-C, Swift), Android, OSX
- Systems
- Go, C, Rust
Different Programming Languages Different types of languages
- Functional
- Object oriented
- Concurrent
- Markup
Ruby
Why this class uses Ruby
- Object Oriented
- Typically used for web
- English-like syntax
- I know it well
Ruby on Rails?
Ruby != Rails
Ruby != Rails
!= means “these things are not equal”
Ruby == Ruby
Ruby == Ruby
== means “these things are equal”
1 == 1 1 == 1
1 == 1
3 == 3
1 == 1
3 == 3
1 == 1
3 == 3
4 == 5
1 == 1
3 == 3
4 == 5
1 == 1 true
3 == 3 true
4 == 5 false
You just learned booleans!
1 == 1 true
3 == 3 true
4 == 5 false
You already knew booleans!
1 == 1 true
3 == 3 true
4 == 5 false
Why not “=”?
Assignment
Because = is used to
assign things
x = 5
eyes = 2
fingers = 10
Assignment
Variables because the
values can change
x = 5
eyes = 2
fingers = 10
horrible_accident
fingers = 9
Using variables
Can be used in
calculations
my_eyes = 2
your_eyes = 2
my_eyes + your_eyes
=> 4
More operators*
* Don’t try to learn all of these today
Other operators
What other things can
you do with variables?
Arithmetic
pies = 3
people = 2
pies + people # 5
pies - people # 1
pies * people # 6
pies / people # 1 (???)
pies % people # 1
pies ** people # 9
Other operators
What other things can
you do with variables?
Comparison
pies = 3
people = 2
pies == people # false
pies != people # true
pies > people # true
pies < people # false
pies >= people # true
pies <= people # false
pies ⇔ people # 1
pies === people # false
Other operators
What other things can
you do with variables?
Logic
pies = 3
people = 2
pies && people
pies and people
pies || people
pies or people
!pies and !people
not pies and not people
Back to variables
Variables aren’t just numbers
Give it a name my_eyes = 2
my_name = “Justin”
Using variables
What if I try this? my_eyes = 2
my_name = “Justin”
my_eyes + my_name
Using variables
What if I try this? my_eyes = 2
my_name = “Justin”
my_eyes + my_name
=> Error
Why does it break?
Variables are
incompatible types
Data structure is
different
my_eyes = 2 # Integer
my_name = “Justin” # String
my_eyes + my_name
=> Error
Common types
- Symbols
- Hashes
- Arrays
- Strings
- Integers
- Floats
- Booleans
symbol = :symbol
hash = {a: 1, b: 2}
array = [1,2,3]
string = “Hello”
integer = 1
float = 1.5
boolean = true
Types we’ll use tonight
- Arrays
- Strings
- Integers
- Booleans
array = [1,2,3]
string = “Hello”
integer = 1
boolean = true
Array
Good for holding lists classmates = [‘Sandy’, ‘Josh’,
‘Amy’, ‘Alfred’]
dice_numbers = [1,2,3,4,5,6]
d20_numbers = dice_numbers +
[7,8,9,10,11,12,13,14,15,16,17,18,19
,20]
Control
Iteration
Doing something for
each item in a list
classmates = [‘Sandy’, ‘Josh’,
‘Amy’, ‘Alfred’]
classmates.each do |classmate|
puts classmate
end
Conditions
If/Else
Do something that
depends on the result
of something else
classmates = [‘Sandy’, ‘Josh’,
‘Amy’, ‘Alfred’]
classmates.each do |classmate|
if classmate == ‘Sandy’
puts classmate
else
puts “who?”
end
end
Code organization
Methods
Pieces of functionality
grouped together
def say_hello
puts “hello”
end
Modules
Group together like
methods
module Greetings
def say_hello
puts “hello”
end
def say_hello_french
puts “bonjour”
end
end
Classes
Group methods related
to a type of object
class Person
attr_accessor :first_name, :
last_name
def full_name
first_name + last_name
end
end
You can program
Concepts you’ve learned
- Assignment
- Data structures
- Iteration
- Conditions
Use of concepts
These basic concepts can get you through most
any problem you’ll have in programming
Advanced topics will help you get better
- Design patterns
- Object oriented programming
- Architecture
- Frameworks
- Libraries
- Abstraction
- More...
Time to code
Ruby
For this class we’ll
use runnable
IRB
Interactive shell
Creating and running a program
my_program.rb
“open with” ruby
Becoming a good developer
Mini-presentation time!
Learn the
language well
Before you dive into Rails
- Learn Ruby well
- Be able to spot the boundaries between Ruby the
language and Rails the framework
Learn the ecosystem
- Learn the tools around Ruby
- Many libraries (Gems) to do specific tasks
Learn best practices
- Version control
- test driven development
- clean code (DRY)
Community involvement
- Code & Supply events
- lectures
- build nights
Continuing education
- Codecademy, Treehouse - Like today, but no instructor
- Ruby Koans
Participate/Give back
- Ask questions. answer anything you can
- IRC - #ruby #codeandsupply
- StackOverflow
- Don’t be afraid of being wrong
Don’t be afraid of
being wrong
Continuing Education

Intro to Programming (1)

  • 1.
    Code & Supply#StarterSeries Why? Job Growth Software development jobs will grow 32% through 2020. Pays well $93,350 median salary (2012) Fun Creative outlet
  • 2.
    Other reasons? Thispresentation Me
  • 3.
    Professional Rails Dev- 5 years Professional Software - 7 years @justinxreese @codeandsupply @builderworksco Starting out Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results
  • 4.
    Code ProgramEditorEnvironment ResultsCode ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results Code ProgramEditorEnvironment Results What is a program? Basically: A file that can be executed More typically: a collection of files that can be executed How does a program run? Think of it like “opening a file with Ruby”
  • 5.
    Code ProgramEditorEnvironment Results DifferentKinds of Programming - Web - Ruby on Rails, JavaScript, Python - Native - iOS (Objective-C, Swift), Android, OSX - Systems - Go, C, Rust Different Programming Languages Different types of languages - Functional - Object oriented - Concurrent - Markup Ruby Why this class uses Ruby - Object Oriented - Typically used for web - English-like syntax - I know it well
  • 6.
    Ruby on Rails? Ruby!= Rails Ruby != Rails != means “these things are not equal” Ruby == Ruby Ruby == Ruby == means “these things are equal”
  • 7.
    1 == 11 == 1 1 == 1 3 == 3 1 == 1 3 == 3 1 == 1 3 == 3 4 == 5 1 == 1 3 == 3 4 == 5
  • 8.
    1 == 1true 3 == 3 true 4 == 5 false You just learned booleans! 1 == 1 true 3 == 3 true 4 == 5 false You already knew booleans! 1 == 1 true 3 == 3 true 4 == 5 false Why not “=”? Assignment Because = is used to assign things x = 5 eyes = 2 fingers = 10 Assignment Variables because the values can change x = 5 eyes = 2 fingers = 10 horrible_accident fingers = 9
  • 9.
    Using variables Can beused in calculations my_eyes = 2 your_eyes = 2 my_eyes + your_eyes => 4 More operators* * Don’t try to learn all of these today Other operators What other things can you do with variables? Arithmetic pies = 3 people = 2 pies + people # 5 pies - people # 1 pies * people # 6 pies / people # 1 (???) pies % people # 1 pies ** people # 9 Other operators What other things can you do with variables? Comparison pies = 3 people = 2 pies == people # false pies != people # true pies > people # true pies < people # false pies >= people # true pies <= people # false pies ⇔ people # 1 pies === people # false Other operators What other things can you do with variables? Logic pies = 3 people = 2 pies && people pies and people pies || people pies or people !pies and !people not pies and not people Back to variables
  • 10.
    Variables aren’t justnumbers Give it a name my_eyes = 2 my_name = “Justin” Using variables What if I try this? my_eyes = 2 my_name = “Justin” my_eyes + my_name Using variables What if I try this? my_eyes = 2 my_name = “Justin” my_eyes + my_name => Error Why does it break? Variables are incompatible types Data structure is different my_eyes = 2 # Integer my_name = “Justin” # String my_eyes + my_name => Error Common types - Symbols - Hashes - Arrays - Strings - Integers - Floats - Booleans symbol = :symbol hash = {a: 1, b: 2} array = [1,2,3] string = “Hello” integer = 1 float = 1.5 boolean = true
  • 11.
    Types we’ll usetonight - Arrays - Strings - Integers - Booleans array = [1,2,3] string = “Hello” integer = 1 boolean = true Array Good for holding lists classmates = [‘Sandy’, ‘Josh’, ‘Amy’, ‘Alfred’] dice_numbers = [1,2,3,4,5,6] d20_numbers = dice_numbers + [7,8,9,10,11,12,13,14,15,16,17,18,19 ,20] Control Iteration Doing something for each item in a list classmates = [‘Sandy’, ‘Josh’, ‘Amy’, ‘Alfred’] classmates.each do |classmate| puts classmate end Conditions If/Else Do something that depends on the result of something else classmates = [‘Sandy’, ‘Josh’, ‘Amy’, ‘Alfred’] classmates.each do |classmate| if classmate == ‘Sandy’ puts classmate else puts “who?” end end
  • 12.
    Code organization Methods Pieces offunctionality grouped together def say_hello puts “hello” end Modules Group together like methods module Greetings def say_hello puts “hello” end def say_hello_french puts “bonjour” end end Classes Group methods related to a type of object class Person attr_accessor :first_name, : last_name def full_name first_name + last_name end end You can program Concepts you’ve learned - Assignment - Data structures - Iteration - Conditions
  • 13.
    Use of concepts Thesebasic concepts can get you through most any problem you’ll have in programming Advanced topics will help you get better - Design patterns - Object oriented programming - Architecture - Frameworks - Libraries - Abstraction - More... Time to code Ruby For this class we’ll use runnable IRB Interactive shell
  • 14.
    Creating and runninga program my_program.rb “open with” ruby Becoming a good developer Mini-presentation time! Learn the language well Before you dive into Rails - Learn Ruby well - Be able to spot the boundaries between Ruby the language and Rails the framework Learn the ecosystem - Learn the tools around Ruby - Many libraries (Gems) to do specific tasks Learn best practices - Version control - test driven development - clean code (DRY)
  • 15.
    Community involvement - Code& Supply events - lectures - build nights Continuing education - Codecademy, Treehouse - Like today, but no instructor - Ruby Koans Participate/Give back - Ask questions. answer anything you can - IRC - #ruby #codeandsupply - StackOverflow - Don’t be afraid of being wrong Don’t be afraid of being wrong Continuing Education