This year both Ruby and I are turning 25 years old. It is amazing to see all the great Ruby code that has been written over time. But we all also have to admit that at some point we have found, or written, Ruby code that was not that great. Even the code that was pretty good at one point, could now be improved, due to the evolution of Ruby.
In this talk I will speak about how it was facing some code in Ruby and RoR open source projects, how this code was refactored and what I learned while doing it.
The presentation is licensed under a CC-BY except the pictures of Ana dressed up, the picture of Evan, the picture with Matz and the gifs. Some pictures of the presentations are taken from https://www.pexels.com and licensed under CC 0. Thanks to all photographers that share they pictures under permissive licenses!
31. a + ba + b
a.concat ba.concat b
a + b + ca + b + c
a.concat b, ca.concat b, c
a | ba | b
a.union ba.union b
a | b | ca | b | c
a.union b, ca.union b, c
38. Yak
ShavingAny apparently useless activity which, by allowing you to overcome
intermediate difficulties, allows you to solve a larger problem
Refactor
OBS
horrible
code
Add new
method to Ruby
Improve
Ruby Array
efficiency
1 month before first Rails release (december 2005). 13 years ago
The Open Build Service (OBS) is a system to build and distribute binary packages from sources
wrote in 2011
Nodoc: public methods not designed for user consumption – don’t want users to rely on this method
Less than one year - october
- We don’t want that both are true
- We want that at least one is true
exclusive or is known as xor in mathematics, hardware and many other programming languages
We add an error except if only one of them is true