-
Constant naming and lookup in Ruby
I thought I had a pretty good understanding of how constant lookup worked in Ruby, but I encountered a surprising piece of behavior recently and I wanted to share it. We had a god model at work that contains thousands of lines of code, much of which is in methods that aren’t truly core to…
-
Default values for hashes in Ruby
I was recently working on some code that involved hashes of arrays. As I was reading through some behaviors of Hash in the Ruby docs, I was delighted to see that you could pass an object to Hash.new and it would be the default value returned when you tried accessing a key in a hash…
-
Don’t make perfect modularity the enemy of a good refactor
I often find myself reviewing pull requests and I will find classes that contain a lot of domain-specific logic that aren’t relevant to the class itself. I’ll point it out and the response is often “I plan to extract this out into a gem, but I just haven’t had a chance/I’ve been busy.” Extracting the…