These are my notes from the second chapter of Polished Ruby Programming by Jeremy Evans. It explores when creating a custom class or a data structure is a good idea and when it’s not.
I started reading Polished Ruby Programming by Jeremy Evans, author of the popular sequel and roda libraries. This is an advanced Ruby book, diving into the design principles, best practices, and trade-offs while programming Ruby. So far, it hasn’t disappointed. Here are my notes from the first chapter.
Everything in Ruby is an object, including the class. When you create a new class, you are basically creating an instance of class
Class. Ruby even allows you to override the
new method on a class, allowing you to customize the creation of all objects.
In my journey to learn and master Ruby, I keep coming across new syntactic sugar every day that makes me happy. This morning, I stumbled upon the double-splat
** operator while learning about the
FileUtils standard library.
John Ousterhout just tweeted that the second edition of A Philosophy of Software Design is out. I’ve been reading the first edition, and it’s been an absolute joy. If you bought the first edition, you can download the new chapters here. Also, check out my notes.
There are two types of finder methods in Active Record; those that return a single instance of the model, e.g.
first, and those that return return an instance of
ActiveRecord::Relation representing a collection of instances, e.g.
group. This post summarizes the query methods that return a single instance.
In one of my previous posts, we saw how to create migrations in Rails to update the database schema. However, creating a migration on its own doesn’t update the database. You have to run the migration to make the changes. This post summarizes all the commands that modify the database.