Sometimes our code examples don't make sense

May 27, 2016

I was reading some technical article the other day that started talking about class hierarchy and used the common setup
class Child < Parent
at which point I got distracted because it occurred to me for the first time--this example doesn't actually make sense! If you're using inheritance in (what I understand to be) the correct way, anyway. It doesn't make sense to subclass Child from Parent, because Child is not in fact a type of Parent. If your parent (ahem) class is going to be Parent, then really any subclasses should be things like SingleParent, or Mother, or AsianDad, or whatever else (and maybe these should all be modules anyway, to mix-in different behaviors...if different kinds of parents are all that different from each other in the first place anyway).

I guess we use the Child < Parent setup because we're thinking of class inheritance like a tree, which we can map in our heads to a family tree, and the "children" inherit some genetic material and behaviors from the parents. But maybe this should instead just be a class like Smith, from which you get many instances of different Smiths, and some instances of Smiths are related to other instances of Smith?

The different kinds of animals (Corgi < Dog) or sports examples might be more sensible generally.

Wow Code, Such Read!

May 5, 2016

This talk was presented as a lightning talk at the New Relic afterparty for RailsConf 2016 and as a 30 minute talk at RubyConf Colombia in MedellĂ­n.

When we learn to code, that usually means learning how to *write* code. However in practice, we spend a lot of time *reading* code instead! It’s the way we find answers to questions about how things work. Reading code efficiently is therefore a very valuable skill. This talk will cover how Ruby developers can improve this skill, with tips for comprehending and debugging code faster. We'll also take a look at how you’d go one level deeper and read Ruby’s own source code, even if you don’t know much about C!

Lightning talk slides:
Response to my talk, on Storify: lightning talk version, RubyConf Colombia.