Significance of the "namespace"

I kind of understand the concept of "namespace". I might loosely compare it to a room in a house.

What I don't understand it the reason for it's existence. I think I would be more comfortable with this concept if I had an idea of how it can be useful (in the Hubitat context). Like why would it be anything other than "hubitat"?

Any explanations would be appreciated.

John

Let's say you and I both write drivers called "Generic Device". There's no way to tell the difference between them without something like namespace to further disambiguate them.

Of course the namespaces could also collide, but it should be a lot less likely if you name your namespace something relatively unique to you. What are the chances that two people choose the same namespace and write a driver with the same name?

There are also clever things you can do that all stem from the namespace making the driver definition additionally unique.

Here's a simple extension of your analogy- you have two TVs in different rooms and you tell a family member to "turn off the TV". How do they know which one you mean?

8 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.