A presentation at Tech Talent South in October 2015 in New Orleans, LA, USA by Gant Laborde
Who is G ant? Who is G ant? Published Author Out of work Co v er Model 15+ Y ears W eb De v T eaches / Speaks / V olunteers Lik es T acos
I totally paid for this image.
WHY? WHY? eleG ant R uby eleG ant R uby Good Cheap Fast
eleG ant L ang uage eleG ant L ang uage Rub y
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_c a se v s c amelC a se snake_c a se v s c amelC a se Bonita Sharif and Jonathan Maletic from the Department of Computer Science K ent State Univ ersity T CP_IP_connection vs tcpIpConnection etc.
eleG ant R uby eleG ant R uby Ro admap Ro admap Basics Linting Concepts
B a sic s B a sic s Making Code Be a utif ul Making Code Be a utif ul
Readability Readability it's important!!!
Names
do_needed_actions_to_item
e
e.write e.save end
??????????????????????????
K eep Methods Small
No Neg ativity No Neg ativity Y ou're the narr ator . It's y our job to guide clearly . St ay Positive St ay Positive
St ay Positive St ay Positive Modus P onens If A then B A therefore B If I get off of work early then I will go with y ou. I got off of work early . Therefore I will go with y ou.
St ay Positive St ay Positive Modus T ollens If A then B Not B therefore not A If a str anger shows, the dog will bark. The dog did not bark Therefore a str anger did not show . - The Hound of the Bask ervilles
St ay Positive St ay Positive
if !user.is_full?
tacos.deploy
end
unless @breakfast == nil
Takeout.deliver(@breakfast)
unless user.is_full?
if @ breakfast
Takeout .deliver ( @breakfast )
Takeout .deliver ( @breakfast ) if @ breakfast
Linting Linting Keeping Code Be a utif ul Keeping Code Be a utif ul
Linting Linting with R ubo cop with R ubo cop et al.
Linting Linting should be friendly should be friendly REMEMBER - It's about people
Git-Hook s Git-Hook s linting on commit linting on commit Mo ving hooks to the repo: https:/ / github.com/icefo x/ git-hooks
Concept s Concept s Be a uty in A b str action Be a uty in A b str action
R uby F an-boy Checklist R uby F an-boy Checklist OOP Dynamic Interpreted Multi-platform Garbage Collection Open Source Intuitiv e / Expressiv e Community Maturity
Higher-order Functions Higher-order Functions Others are first-order functions NO T T O BE CONFUSED WITH first-class functions
Functional Progr amming Functional Progr amming map, collect, select, reject, find, an y?, all?, sort
Blo c s Pro c s and Blo c s Pro c s and L ambda s L ambda s
The Need The Need
Array.new(
5 )
=> [nil, nil, nil, nil, nil] Array.new(
5 , 100 )
=> [
100 , 100 , 100 , 100 , 100 ]
5 , rand( 100 ))
65 , 65 , 65 , 65 , 65 ]
5 ) { rand( 100 ) }
55 , 69 , 5 , 68 , 54 ]
Let's Code Let's Code E x ample s of Clos ure s E x ample s of Clos ure s
E very one Conf used? E very one Conf used? GOOD! https:/ / github.com/ gantman/ eleGant
THE END THE END * Applause *
View eleGant Ruby on Notist.
Dismiss
A short jaunt through the world of Ruby and it's beauty. How to write clear and concise Ruby code that others will appreciate.