Upload
justin-reese
View
249
Download
2
Embed Size (px)
Citation preview
Code & Supply #StarterSeries
Why?
Job Growth
Software development jobs will grow 32% through 2020.
Pays well
$93,350 median salary (2012)
Fun
Creative outlet
Professional Rails Dev - 5 yearsProfessional 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 true3 == 3 true4 == 5 false
You just learned booleans!1 == 1 true3 == 3 true4 == 5 false
You already knew booleans!1 == 1 true3 == 3 true4 == 5 false Why not “=”?
AssignmentBecause = is used to assign things
x = 5
eyes = 2
fingers = 10
AssignmentVariables because the values can change
x = 5
eyes = 2
fingers = 10
horrible_accident
fingers = 9
Using variablesCan be used in calculations
my_eyes = 2
your_eyes = 2
my_eyes + your_eyes
=> 4More operators*
* Don’t try to learn all of these today
Other operatorsWhat other things canyou 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 operatorsWhat other things canyou 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 operatorsWhat other things canyou 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 numbersGive it a name my_eyes = 2
my_name = “Justin”
Using variablesWhat if I try this? my_eyes = 2
my_name = “Justin”
my_eyes + my_name
Using variablesWhat 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
ArrayGood 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
IterationDoing something foreach item in a list
classmates = [‘Sandy’, ‘Josh’, ‘Amy’, ‘Alfred’]
classmates.each do |classmate|
puts classmate
end
Conditions
If/ElseDo something that depends on the resultof something else
classmates = [‘Sandy’, ‘Josh’, ‘Amy’, ‘Alfred’]
classmates.each do |classmate|
if classmate == ‘Sandy’
puts classmate
else
puts “who?”
end
end
Code organization
MethodsPieces of functionality grouped together
def say_hello
puts “hello”
end
ModulesGroup together like methods
module Greetings
def say_hello
puts “hello”
end
def say_hello_french
puts “bonjour”
end
end
ClassesGroup methods relatedto 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
RubyFor this class we’lluse 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 ofbeing wrong
Continuing Education