eleGant Ruby

A presentation at Tech Talent South in October 2015 in New Orleans, LA, USA by Gant Laborde

Slide 1

Slide 1

Slide 2

Slide 2

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  

Slide 3

Slide 3

I totally paid for this image.

Slide 4

Slide 4

WHY? WHY? eleG ant R uby eleG ant R uby Good Cheap Fast

Slide 5

Slide 5

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;

  }

}

Slide 6

Slide 6

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.

Slide 7

Slide 7

eleG ant R uby eleG ant R uby Ro admap Ro admap Basics Linting Concepts

Slide 8

Slide 8

B a sic s B a sic s Making Code Be a utif ul Making Code Be a utif ul

Slide 9

Slide 9

Readability Readability it's important!!!

Slide 10

Slide 10

Names

def

do_needed_actions_to_item

e

  e.write

  e.save

end

??????????????????????????

Slide 11

Slide 11

K eep Methods Small

Slide 12

Slide 12

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

Slide 13

Slide 13

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.

Slide 14

Slide 14

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 

Slide 15

Slide 15

Slide 16

Slide 16

St ay Positive St ay Positive

Slide 17

Slide 17

St ay Positive St ay 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

Slide 18

Slide 18

Linting Linting Keeping Code Be a utif ul Keeping Code Be a utif ul

Slide 19

Slide 19

Linting Linting with R ubo cop with R ubo cop et al.

Slide 20

Slide 20

Linting Linting should be friendly should be friendly   REMEMBER - It's about people

Slide 21

Slide 21

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

Slide 22

Slide 22

Concept s Concept s Be a uty in A b str action Be a uty in A b str action

Slide 23

Slide 23

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

Slide 24

Slide 24

Higher-order Functions Higher-order Functions Others are first-order functions NO T T O BE CONFUSED WITH first-class functions

Slide 25

Slide 25

Functional Progr amming Functional Progr amming map, collect, select, reject, find, an y?, all?, sort

Slide 26

Slide 26

Blo c s Pro c s and Blo c s Pro c s and L ambda s L ambda s      

Slide 27

Slide 27

The Need 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 ]

Slide 28

Slide 28

Let's Code Let's Code E x ample s of Clos ure s E x ample s of Clos ure s

Slide 29

Slide 29

E very one Conf used? E very one Conf used? GOOD! https:/ / github.com/ gantman/ eleGant

Slide 30

Slide 30

THE END THE END * Applause *