0 0
WP Ad Inserter plugin
Read Time:1 Minute, 11 Second

As I always say, naming things is hard. We’ve already talked about this in a previous article.

By creating a simple and coherent dictionary, your classes will have better names because you are representing the same idea with the same name. This improves code readability and searchability. Also, by simply looking at the names of your classes you can grasp the meaning of them.

Say that we have 3 objects that perform similar operations: they download some content from external sources.

class YouTubeDownloader { } class TwitterDownloadManager { } class FacebookDownloadHandler { }

Here we are using 3 words to use the same concept: Downloader, DownloadManager, DownloadHandler. Why??

So, if you want to see similar classes, you can’t even search for “Downloader” on your IDE.

The solution? Use the same name to indicate the same concept!

class YouTubeDownloader { } class TwitterDownloader { } class FacebookDownloader { }

It’s as simple as that! Just a small change can drastically improve the readability and usability of your code!

So, consider also this small kind of issue when reviewing PRs.


A common dictionary helps to understand the code without misunderstandings. Of course, this tip does not refer only to class names, but to variables too. Avoid using synonyms for objects (eg: video and clip). Instead of synonyms, use more specific names (YouTubeVideo instead of Video).

Any other ideas?

👉 Let’s discuss it on Twitter or on the comment section below!


Source: https://www.code4it.dev/cleancodetips/use-same-name-for-same-concept

Previous post How to deploy Django app using Docker
Best 2 Ways to Find GCD of Two Numbers Using Constructor in Java Next post Best 2 Ways to Find GCD of Two Numbers Using Constructor in Java

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.