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 professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
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)