SlideShare a Scribd company logo
1 of 23
Most common mistakes of
workshops’ applicants
Robert Kuśmirek
String concatenation
def full_name_with_title
full_name + ” [“ + title + “]”
end
It works… But it’s not ruby!
def full_name_with_title
“#{full_name} [#{title}]”
end
Use string interpolation
In 99.9999% cases that’s what you need
if kitten.cute?
attempt_capture
else # highly unlikely
kitten.groom
kitten.apply_ribbon
kitten.pat_on_the_head
end
Control flow
I’d rather see you using Guard Clause
Again, this is a better choice in 99.99999% cases
return attempt_capture if kitten.cute?
kitten.groom
kitten.apply_ribbon
kitten.pat_on_the_head
During code review, what would you rather see…
~ or ~
Big Commits
Exactly.
N+1 Query
# models
class Cat < ActiveRecord::Base
belongs_to :crazy_cat_lady
end
class CrazyCatLady < ActiveRecord::Base
has_many :cats
end
# in controller
expose(:cats) { Cat.limit(5) }
# in view
cats.each do |cat|
= cat.crazy_cat_lady
end
This results in mayhem in your logs
Cat Load (0.9ms) SELECT 'cats'.* FROM 'cats'
CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE
'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 1]]
CrazyCatLady Load (0.3ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE
'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 2]]
CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE
'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 3]]
CrazyCatLady Load (0.3ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE
'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 4]]
CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE
'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 5]]
Eager loading for the rescue!
expose(:cats) { Cat.includes(:crazy_cat_ladies).limit(5)}
Cat Load (0.4ms) SELECT 'cats'•.* FROM 'cats'•
CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'•.* FROM 'crazy_cat_ladies'•
WHERE 'crazy_cat_ladies'•.'•id'•IN (1,2,3,4,5)
Much better.
Bullet
def cuddle_with_kitten(options = {})
# cuddling-related code
end
cuddle_with_kitten({cat: ‘Pinky’, cuddle: :furiously})
So many options!
You can drop the {braces} when options are
the last argument!
How cool is that? And cleaner too.
cuddle_with_kitten(cat: ‘Pinky’, cuddle: :furiously)
Decorator Pattern
DON’T push API tokens and secrets to repos.
Everytime you do it a cute kitten dies.
Use secrets.yml.
Or figaro.
Or something.
Anything!
There are variables in scss.
Use them!
.kitten {
fur-color: #e2e2e2;
}
.horse {
fur-color: #e2e2e2; <= duplication spotted!
}
Duplication is #uncool.
$gray-fur-color: #e2e2e2;
.kitten {
fur-color: $gray-fur-color;
}
.horse {
fur-color: $gray-fur-color;
}
And last but not least...
# in view
= “#{t(‘something.clever’)}”
This is HAML, doug!
It tries very hard to be your best friend!
# in view
= t(‘something.clever’)}
~ or ~
#{t(‘something.even.cleverer’)} # Look, Ma! No ‘=’!
Most common mistakes of workshops applicants

More Related Content

Similar to Most common mistakes of workshops applicants

A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesA linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesTchelinux
 
Grails GORM - You Know SQL. You Know Queries. Here's GORM.
Grails GORM - You Know SQL. You Know Queries. Here's GORM.Grails GORM - You Know SQL. You Know Queries. Here's GORM.
Grails GORM - You Know SQL. You Know Queries. Here's GORM.Ted Vinke
 
How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)Toria Gibbs
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Craig Francis
 
Zen and the Art of Python
Zen and the Art of PythonZen and the Art of Python
Zen and the Art of PythonClayton Parker
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven PractisesRobert MacLean
 
Code Fast, Die Young, Throw Structured Exceptions
Code Fast, Die Young, Throw Structured ExceptionsCode Fast, Die Young, Throw Structured Exceptions
Code Fast, Die Young, Throw Structured ExceptionsJohn Anderson
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and JavaAli MasudianPour
 
Search Engines: How They Work and Why You Need Them
Search Engines: How They Work and Why You Need ThemSearch Engines: How They Work and Why You Need Them
Search Engines: How They Work and Why You Need ThemToria Gibbs
 
Gigigo Ruby Workshop
Gigigo Ruby WorkshopGigigo Ruby Workshop
Gigigo Ruby WorkshopAlex Rupérez
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadiesAlicia Pérez
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 
A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017Toria Gibbs
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love RubyBen Scheirman
 
Refatoração + Design Patterns em Ruby
Refatoração + Design Patterns em RubyRefatoração + Design Patterns em Ruby
Refatoração + Design Patterns em RubyCássio Marques
 

Similar to Most common mistakes of workshops applicants (20)

A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesA linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
 
Grails GORM - You Know SQL. You Know Queries. Here's GORM.
Grails GORM - You Know SQL. You Know Queries. Here's GORM.Grails GORM - You Know SQL. You Know Queries. Here's GORM.
Grails GORM - You Know SQL. You Know Queries. Here's GORM.
 
How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)How Search Engines Work (A Thing I Didn't Learn in University)
How Search Engines Work (A Thing I Didn't Learn in University)
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()
 
Intro to ruby
Intro to rubyIntro to ruby
Intro to ruby
 
Zen and the Art of Python
Zen and the Art of PythonZen and the Art of Python
Zen and the Art of Python
 
Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9Hidden Gems of Ruby 1.9
Hidden Gems of Ruby 1.9
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
 
Code Fast, Die Young, Throw Structured Exceptions
Code Fast, Die Young, Throw Structured ExceptionsCode Fast, Die Young, Throw Structured Exceptions
Code Fast, Die Young, Throw Structured Exceptions
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and Java
 
Search Engines: How They Work and Why You Need Them
Search Engines: How They Work and Why You Need ThemSearch Engines: How They Work and Why You Need Them
Search Engines: How They Work and Why You Need Them
 
Gigigo Ruby Workshop
Gigigo Ruby WorkshopGigigo Ruby Workshop
Gigigo Ruby Workshop
 
Backbone intro
Backbone introBackbone intro
Backbone intro
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadies
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017A Search Index is Not a Database Index - Full Stack Toronto 2017
A Search Index is Not a Database Index - Full Stack Toronto 2017
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Refatoração + Design Patterns em Ruby
Refatoração + Design Patterns em RubyRefatoração + Design Patterns em Ruby
Refatoração + Design Patterns em Ruby
 
Django Celery
Django Celery Django Celery
Django Celery
 
C#6 - The New Stuff
C#6 - The New StuffC#6 - The New Stuff
C#6 - The New Stuff
 

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Most common mistakes of workshops applicants

  • 1. Most common mistakes of workshops’ applicants Robert Kuśmirek
  • 3. It works… But it’s not ruby!
  • 4. def full_name_with_title “#{full_name} [#{title}]” end Use string interpolation In 99.9999% cases that’s what you need
  • 5. if kitten.cute? attempt_capture else # highly unlikely kitten.groom kitten.apply_ribbon kitten.pat_on_the_head end Control flow
  • 6. I’d rather see you using Guard Clause Again, this is a better choice in 99.99999% cases return attempt_capture if kitten.cute? kitten.groom kitten.apply_ribbon kitten.pat_on_the_head
  • 7. During code review, what would you rather see… ~ or ~ Big Commits
  • 9. N+1 Query # models class Cat < ActiveRecord::Base belongs_to :crazy_cat_lady end class CrazyCatLady < ActiveRecord::Base has_many :cats end # in controller expose(:cats) { Cat.limit(5) } # in view cats.each do |cat| = cat.crazy_cat_lady end
  • 10. This results in mayhem in your logs Cat Load (0.9ms) SELECT 'cats'.* FROM 'cats' CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE 'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 1]] CrazyCatLady Load (0.3ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE 'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 2]] CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE 'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 3]] CrazyCatLady Load (0.3ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE 'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 4]] CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'.* FROM 'crazy_cat_ladies' WHERE 'crazy_cat_ladies'.'id' = ? ORDER BY 'crazy_cat_ladies'.'id' ASC LIMIT 1 [["id", 5]]
  • 11. Eager loading for the rescue! expose(:cats) { Cat.includes(:crazy_cat_ladies).limit(5)}
  • 12. Cat Load (0.4ms) SELECT 'cats'•.* FROM 'cats'• CrazyCatLady Load (0.4ms) SELECT 'crazy_cat_ladies'•.* FROM 'crazy_cat_ladies'• WHERE 'crazy_cat_ladies'•.'•id'•IN (1,2,3,4,5) Much better.
  • 14. def cuddle_with_kitten(options = {}) # cuddling-related code end cuddle_with_kitten({cat: ‘Pinky’, cuddle: :furiously}) So many options!
  • 15. You can drop the {braces} when options are the last argument! How cool is that? And cleaner too. cuddle_with_kitten(cat: ‘Pinky’, cuddle: :furiously)
  • 17. DON’T push API tokens and secrets to repos. Everytime you do it a cute kitten dies.
  • 18. Use secrets.yml. Or figaro. Or something. Anything!
  • 19. There are variables in scss. Use them! .kitten { fur-color: #e2e2e2; } .horse { fur-color: #e2e2e2; <= duplication spotted! }
  • 20. Duplication is #uncool. $gray-fur-color: #e2e2e2; .kitten { fur-color: $gray-fur-color; } .horse { fur-color: $gray-fur-color; }
  • 21. And last but not least... # in view = “#{t(‘something.clever’)}”
  • 22. This is HAML, doug! It tries very hard to be your best friend! # in view = t(‘something.clever’)} ~ or ~ #{t(‘something.even.cleverer’)} # Look, Ma! No ‘=’!