SlideShare a Scribd company logo
My month with Ruby
Who is this guy?
- Alex Tomovski
- Backend Developer (primarily)
- Scala, Java, Groovy
- Recently crossed to the dark side… JS
How did I end up coding Ruby?
- Joined Wix in the summer.
- No project was waiting for me.
- Finally after two weeks I got a call…
How did the colleagues react when I
told them I’ll be doing Ruby?
Some of them got creative :)
What was I supposed to build?
- Thin Rest Wrapper
- But why?
- Make developers life easier.
- Annoying request signing logic
- Document and provide examples for the APIs
The API
Where do you start???
- Book: The Ruby Programming language
- IRB
- Setup the project
- Look at other examples/tools
- www.ruby-toolbox.com
Setting up the project
- Bundler and Rake
- Love at first sight (especially for bundler)
I want less of this: and more of this:
Hello World!
- Tests
- RSpec + Guard
- Tests run in the background
- Immediate feedback
- WIN!
Testing a dynamic language
- Paranoia!
- What happens if someone
passes the wrong type?
- Guard statements
everywhere?
- Wait do I care?
Integration (e2e) Tests
- Easier refactoring
- Faster bug discovery
- VCR
- https://github.com/vcr/vcr
- Records HTTP Interactions
- Fast re-execution
- Helps with debugging
VCR Cassette
First Impressions
- Easy to learn
- Readability
- Super FUN!
Guard Statements!
Mutability
- Hard to come back to it
- Side effects
- Freeze?
Blocks? Lambdas? Procs?
Vision
- One entry point (the client)
- Minimal configuration
- Optional extensive configuration
Structuring the gem
- Modules
- Mixins
REST Client VS. Faraday
- Ease of use
- Extensibility
- Plugable middleware
- Configuration
Faraday
Classes or Hashes?
- Response handling
Classes
- Easy data access
- Hard to create
Introducing Hashie
- Best of two worlds
- https://github.com/intridea/hashie
Hashie Example
Too much magic
- It was all great until this:
/hashie/dash.rb:41:in `block in property': wrong number of arguments (1 for 0)
(ArgumentError)
from /hashie-3.2.0/lib/hashie/hash.rb:48:in `flexibly_convert_to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:34:in `block in to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:20:in `each'
from /hashie-3.2.0/lib/hashie/hash.rb:20:in `to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:42:in `to_json'
A day latter…
Monkey Patching
And we’re Almost :) done
- Final thoughts:
- Threading
- Meta programming
- Would I use Ruby again?
Thank you!
Questions, Comments?
Repo: https://github.com/wix/wix-hive-ruby

More Related Content

What's hot

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
Yukti Kaura
 
NodeJS
NodeJSNodeJS
EhTrace -- RoP Hooks
EhTrace -- RoP HooksEhTrace -- RoP Hooks
EhTrace -- RoP Hooks
Shane Macaulay
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and Redis
York Tsai
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
Jaeju Kim
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2
Vinci Rufus
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
IsaacSchlueter
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
Arjun Sreekumar
 
Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
James Ford
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Aziz Ali
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
Michał Konarski
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
Tim Sommer
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Joseph de Castelnau
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applications
railsconf
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
Jackson Tian
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
VivochaLabs
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
Marko Mitranić
 
NodePDX Slides
NodePDX SlidesNodePDX Slides
NodePDX Slides
Kyle Drake
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
Sagiv Ofek
 

What's hot (20)

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
NodeJS
NodeJSNodeJS
NodeJS
 
EhTrace -- RoP Hooks
EhTrace -- RoP HooksEhTrace -- RoP Hooks
EhTrace -- RoP Hooks
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and Redis
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applications
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
 
NodePDX Slides
NodePDX SlidesNodePDX Slides
NodePDX Slides
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 

Similar to My month with Ruby

SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
Jesse Vincent
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
Will Green
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
Barry Jones
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Kyle Drake
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
elliando dias
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
Ilya Grigorik
 
Java
JavaJava
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
cacois
 
The story of language development
The story of language developmentThe story of language development
The story of language development
Hiroshi SHIBATA
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
Ánh Nguyễn
 
Lightweight APIs in mRuby
Lightweight APIs in mRubyLightweight APIs in mRuby
Lightweight APIs in mRuby
Pivorak MeetUp
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury
 
Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)
Bertrand Delacretaz
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
Paul Gallagher
 
Node Security: The Good, Bad & Ugly
Node Security: The Good, Bad & UglyNode Security: The Good, Bad & Ugly
Node Security: The Good, Bad & Ugly
Bishan Singh
 
Introduction To Rails
Introduction To RailsIntroduction To Rails
Introduction To Rails
Eric Gruber
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
IT Weekend
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in Production
Docker, Inc.
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 

Similar to My month with Ruby (20)

SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
Java
JavaJava
Java
 
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Lightweight APIs in mRuby
Lightweight APIs in mRubyLightweight APIs in mRuby
Lightweight APIs in mRuby
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
Node Security: The Good, Bad & Ugly
Node Security: The Good, Bad & UglyNode Security: The Good, Bad & Ugly
Node Security: The Good, Bad & Ugly
 
Introduction To Rails
Introduction To RailsIntroduction To Rails
Introduction To Rails
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in Production
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 

Recently uploaded

Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 

Recently uploaded (20)

Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 

My month with Ruby

Editor's Notes

  1. Thin Rest Wrapper around a collection of API’s that Wix exposes to third party application developers.
  2. How do you choose tools when you have no experience and no one to ask? You use google :) and find ruby toolbox. This really helped me and almost all (I’ll talk about exceptions in a minute) of the tools that used are based on the stats from this place. IRB - Although scala has the repl and I always found it useful, what I loved about the IRB and found more convenient is the fact that you can simply require gems and play around with them.
  3. Coming from the world of Scala/Java where you need to choose between maven gradle or sbt for your project using bundler and rake was like a dream come true. And what I truly loved about them is the simplicity and the fact that the dependency management is separated from the tasks part! No more xmls or spaghetti code for dependencies, build ,package and test tasks.
  4. Guard running the tests. Amazing when coming from Scala!
  5. No compiler no types I need to test everything! During my first week this was the attitude that I had and I wrote a whole bunch of unit tests that had nothing to do with behaviour! But I quickly realised that I’m trying swim against the tide here. I heard/read various opinions on how you should write more unit tests when you are coding in a dynamic language but what I actually found the most useful are integration tests! But say you had a test that tested the system/component from the outside? Would that help? IMHO it might and it might help you catch bugs faster and thats why we need integration and e2e tests….
  6. As we spoke just a minute more often than not we need to refactor some bits of the system or in this case library. This will involve changing sometimes multiple components and although unit tests are great in this case they were not enough for me to feel comfortable making those changes. Also early in that one month I found myself creating bugs :) and these tests made sure to keep me in line. OK I realised I needed integration and end 2 end tests but I now had to add them to the project. What I wanted was: 1. Fast integration tests to run with guard. 2. E2E tests to exercise the library against a test app. After playing around a bit I realised that the tests in both cases are the same the only thing that was diferent is that I wanted the integration tests to run faster :) And as I already learned by now: There must be a GEM for it :) and there was VCR. Its an awesome tool basically it records the HTTP interactions and enables you to re-execute them in a fast manner locally while you are developing. Exactly what I needed. Another nice thing about VCR was that the interactions were saved as yaml files and were very readable so I found myself looking through them to resolve some issues both on the server and in the library iteslf. OK now that I had the tests set up it was time to actually write the gem…
  7. By this point I’ve already had a few weeks of coding in Ruby… The first impression that I had about the language was how easy it was to pick it up and how naturaly it was to write code in Ruby. The code that I would write was almost like english making it the most redable language I’ve had the pleasure to work with. Not everything is pink in Ruby land though :) Mutability was something that I had to get used to coming from Scala.
  8. Here is the outline of how I wanted the gem to look like: One entry point…. meaning I the client would have to know only about a single class and easily pull it in. Minimal configuration… again I wanted developers to be able to require the gem and be able to start using it in a matter of min without having to go through a ton of documentation. Optional extensive configuration… for more advanced clients I wanted them to be able to configure anything from logging to http timeouts to headers. With that in mind and having looked at a couple of examples :) I set out to write the gem.
  9. First thing that I loved about Ruby was the modules! Lets look at the example of the structure that I was able to give to my code. So lets start with the client it pulls in the Rest API. The rest api defines the different groups of apis that it has. And finally lets look at the first one. One thing that was hard to get used to is that you can call methods from the parent object but that again comes down to me not being used to the dynamic nature of the language :) Now that I had this walking skeleton in place it was time to actually make some http calls and make the first e2e test pass. ??similar to Scala traits they are similar in the sense that modules are mixins and mixins are traits that can have state.
  10. Although the title of the slide looks like there was some battle :) between the two. To be honest there was not after maybe a day playing around with the two these were the takeaways: REST Client is for sure easier to use… It has a simple interface BUT but you pay for that simplicity by the lack of extensibility. This was the thing that made up my mind about Faraday! My code was encapsulated in small “racks” that I pluged in and they did one very specific job! For example the error handling [show slide]. And also it fit nicely with my initial idea to expose a fair amount of configuration to the advanced end user.
  11. Once I had the the whole thing set up and got my first response back from the gem I was not very satisfied with the response… :) I got a hash back… this was not the usage I had in mind. How I actually wanted this gem to work is that the user would receive an object back that he can access. For example: [show example] So I started creating this kind of objects by hand and added some parsing logic to populate them it looked great until moment I actually wanted to send a request to create a contact for example… and that looked like this [show example] and this was also not what I wanted… and if that was not enough I realised that I also need some validation on the objects. And again before long I applied the most valuable lesson in Ruby that I’ve learned so far and that is: If you are doing something complicated stop there is a gem for it :D And there was Introducing hashie the best of two worlds [show example] with hashie I was able to give the flexibility for developers to choose their own style in which they read or create objects.
  12. I was making rapid progress with Hashie. Things were so easy :) I even took it a step further and generated some of the classes from a predefined json schema. Until I got this error. First things first this didnt tell me anything to be honest so I started debugging and after maybe a day or so I figured it out :) one of the responses that I was getting contained a field named method. And guess what hashie did when it found a field like that? Well it declared a method called method :) and kaboom you loose one of the base object methods. And its just a ticking bomb until this pops up somewhere on runtime.
  13. Lets start off with the fact that I had to solve my problem. It was too late to go back and do a reafctor on the library because of one “small” issue. So I resorted to I suppose everyone in this room has done once or twice in their Ruby career and that is Monkey Patching. I suppose you have read heard argued on this subject so I wont take too much of your time and I will break my view on it down to 3 simple points. Obviously the good part is that the language enabled me to go around an issue or to add functionality to a class where needed. This fits nicely with the OOP open closed principle. Well the bad thing here is that I can override or practically erase a behaviour of any class. Thus violating the “closed for modification” part of the open closed principle. Once you monkey patch for the first time it works like heroin :) you just want to do it more and every problem looks like a perfect fit for monkey patching. And if you are not carful you can endup with an ugly unmanageable code base. And although I lack the experience to speak about this in the Ruby world we have something very similar in Scala called implicits which is basically allows you to extend a class with new behaviour. But what happens usually when you learn implicits for the first time is that you use them everywhere you go crazy with them. And then good luck reading the code or debugging through it.