DEV Community

ShinaBR2
ShinaBR2

Posted on • Updated on

Uniqueness

Hi, I am a lazy frontend developer come from Vietnam, the man looking for original values.


When start writing this article, I feel a bit hard to choose the
correct tags. Because this term "uniqueness" effects not only in programming but also in everything in our industry, or even in human life. I will show you now.

The Importance of Uniqueness thinking

Let's talk about our programming adventure first. We all know there are lots of problems that we faced. We need the core concepts, we need the design patterns, for what? - For resolving some specific problems? No, actually not. We need them because they are our light in all day long, hard but interesting adventure.

But have you ever think about one rule of thumb of those concepts, design patterns? One thing can rule them all?

My opinionated answer is the "uniqueness".

Uniqueness in programming

One of my favorite quotes in programming is:

There are only two hard things in Computer Science: cache invalidation and naming things.

-- Phil Karlton

It is okay if you have never heard about that. As soon as you realized these two things, the stronger thinking you have.

I considered this quote for many years. Because I am too lazy to remember two things, I want to figure out only one thing, one thing can lead to them, that is uniqueness. I realized long time ago before able to writing this article.

Why uniqueness can lead to two these things?

  • First, one hard step to achieve caching is defining cache key. Because it is a key, it needs to be unique.
  • Second, naming things, the name should be unique in current "scope". The term "scope" is different in different programming languages, but the core idea is the space that a variable has its meaning.

So I can think, if I can resolve uniqueness problem, all the remaining things should be easy. That is a good answer for somebody lazy like me.

Some other easy to see example to show how important of uniqueness is:

  • Primary key in database. All we already known.
  • Key for each item in a list. If you are working with React, please refer to this to see why it is so important.
  • Global variable name. If you have worked with jQuery, you will understand why $ need to be unique (back to naming things, back to unique again).
  • Lots of algorithms were born to resolve one problem: generate a unique string.
  • Identity: every user need to be identified right? And we need a unique id for it correct?
  • All other keys.

Of course please feel free if you find any other case that we need to make a thing unique.

I hope you can see the feeling I had about this single term. Now we go to the next section.

Uniqueness in everything

Like I said above, not only in programming, the uniqueness should be also a great impact in your human life.

The answer is simple, but actually not easy to do: because all of us, want to be unique among other people.

In an interview, every single person in us, want to be the best candidate. This actually mean we need to be unique among the others.
In our company, we strongly need to be unique, nobody wants people easy to find another one replace me.
In all of our relationships, we indeed need that unique thing.

These are enough for me. One thing, rule all other things.

So ...

How can I think uniqueness

In programming first, you can try to think about something that I mentioned in the first part before considering other problems. You may think those are easy. Yes, but if you practice it enough, you will easy to see the core of almost problems you face. Always think about uniqueness, how to make something, some object unique, how to identify an object or variable and so on.

In our human life, it is totally depends on you. But somehow similar to programming, you will become more brilliant. A good example is, how to guide a tourist to follow the right way? (You might need to find out some *** thing).

That's all! Thanks for your valuable time. Love ya and see you guys in next articles.

@shinabr2

Top comments (0)