Read more

Think twice before using application names in your variables and methods

Judith Roth
January 16, 2018Software engineer at makandra GmbH

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

Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
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 by Judith Roth to makandra dev (2018-01-16 09:55)