Who is Gant?
Published Author
Out of work Cover Model
15+ Years Web Dev
Teaches / Speaks / Volunteers
Likes Tacos
I totally paid for this image.
WHY?
eleGant Ruby
Good
Cheap
Fast
eleGant Language
Ruby
def paidMore amount
proc { |e| e.salary > amount }
end
C#
public Predicate<Employee>
PaidMore(int amount) {
return delegate(Employee e) {
return e.Salary > amount;
}
}
snake_case vs camelCase
Bonita Sharif and Jonathan Maletic from the Department of Computer Science Kent State University
TCP_IP_connection vs tcpIpConnection etc.
eleGant Ruby
Roadmap
Basics
Linting
Concepts
Basics
Making Code Beautiful
Readability
Readability
it's important!!!
Names
def do_needed_actions_to_item e
e.write
e.save
end
??????????????????????????
Keep Methods Small
No Negativity
You're the narrator. It's your job to guide clearly.
Stay Positive
Stay Positive
Modus Ponens
- If A then B
- A
- therefore B
If I get off of work early then I will go with you.
I got off of work early.
Therefore I will go with you.
Stay Positive
Modus Tollens
- If A then B
- Not B
- therefore not A
If a stranger shows, the dog will bark.
The dog did not bark
Therefore a stranger did not show.
Stay Positive
Stay Positive
if !user.is_full?
tacos.deploy
end
unless @breakfast == nil
Takeout.deliver(@breakfast)
end
unless user.is_full?
tacos.deploy
end
if @breakfast
Takeout.deliver(@breakfast)
end
Takeout.deliver(@breakfast) if @breakfast
Linting
Keeping Code Beautiful
Linting
with Rubocop
et al.
Linting
should be friendly
REMEMBER - It's about people
Git-Hooks
linting on commit
Moving hooks to the repo:
https://github.com/icefox/git-hooks
Concepts
Beauty in Abstraction
Ruby Fan-boy Checklist
- OOP
- Dynamic
- Interpreted
- Multi-platform
- Garbage Collection
- Open Source
- Intuitive / Expressive
- Community
- Maturity
Higher-order Functions
Others are first-order functions
NOT TO BE CONFUSED WITH first-class functions
Functional Programming
map, collect, select, reject, find, any?, all?, sort
Blocs Procs and Lambdas
The Need
Array.new(5)
=> [nil, nil, nil, nil, nil]
Array.new(5, 100)
=> [100, 100, 100, 100, 100]
Array.new(5, rand(100))
=> [65, 65, 65, 65, 65]
Array.new(5) { rand(100) }
=> [55, 69, 5, 68, 54]
Let's Code
Examples of Closures
Everyone Confused?
GOOD!
https://github.com/gantman/eleGant
THE END
*Applause*
eleGant Ruby
By Gant Laborde
eleGant Ruby
A short jaunt through the world of Ruby and it's beauty.
- 3,050