There are only two hard things in Computer Science: cache invalidation and naming things.
â Phil Karlton
Naming is such an incredibly important part of software development. A well chosen name can make complex code significantly more readable by providing additional context.
For example, compare this version:
raise ArgumentError if a.size != b.size a = a.chars b = b.chars a.each_with_index.inject(0) do|memo,value_index_pair| value, index = value_index_pair if value == b[index] memo else memo + 1 end end end
To a version with better naming
check_for_valid_size!(a,b) pairs_of_characters(a,b).map do |pair| pair_equal?(pair) ? 0 : 1 end.sum end
The implementations are identical, but by replacing procedural blocks of code with what that code is meant to do, itâs much easier for an unfamiliar user to reason about what is happening.
As the importance of naming becomes more and more clear, itâs leading me to change my language. One primary example is my increasing use of the word âyâall[^1].”
Over the last 12 years, Iâve worked on remote teams with female software developers more often that not. During that time, Iâve felt uncomfortable using the phrase âguysâ as a collective. While people say it can be used in a gender neutral way, the fact that we say âguys and girls?â makes me uncomfortable.
To some folks, this may seem like a minor issue. Thatâs not the case if youâre one of the people being excluded. I saw this with my kids. When my boys were little, my youngest was very upset that he couldnât be a doctor. I asked him why and he told me âbecause all doctors are girls.â In his life, he had only seen female physicians which made him think he couldnât be part of that group. I want to make sure Iâm not the one contributing to the gender an racial biases we see in CS[^2].
With as much time as good developers spend thinking about variable and class names, shouldnât we spend at least as much time making sure our language isnât exclusionary? What phrase do you use? Let me know at @mikemangino on twitter.
[^1]: I was happy to find a list of alternatives. Iâve tried most of these and settled on yâall in most cases.
[^2]: Hereâs a few other terms to think before using.