Posted 11 months ago. Visible to the public.

Think twice before using application names in your variables and methods

I recently had fun with replacing a custom video plattform ("mycustomtv") in one of our applications. I learned a lot about naming stuff.

youtube_mycustomtv_chooser is a bad name for a directive.

Why?

  • if you add, for example, other video systems like vimeo, the name of the method either lies or will get longer.
  • if you replace one system, you will have to change the method and all of its occurrences (and you're very lucky if it is only one poorly named thing in your application)

What would be a better solution?

Abstract from the systems you use. For example: video_type_chooser. Abstracting from system and application names also makes your code more reusable.

I think it's good not to abstract for something like an importer, that really only is used for your custom system. Just don't name everything in your application like your custom system. And also don't name everything in your application like your application - it does not add value but makes code harder to adopt for different use-cases.

[/rant]

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Judith Roth
Last edit:
11 months ago
by Judith Roth
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more