Read more

Think twice before using application names in your variables and methods

Deleted user #4117
January 16, 2018Software engineer

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

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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]

Posted to makandra dev (2018-01-16 09:55)