2019-01-30

Should double colons ever be used for class inclusions defined type instantiations (to indicate absolute namespacing)?

When I started using Puppet, a long while ago, most facts were used in what is now called their legacy form- just as bare variables. For example:

$osfamily

We got into the habit of absolute namespacing them to ensure we were addressing the variable at the top scope.

$::osfamily

Further, because you could also have a scoping issue when accessing other structures, such as classes and defined types, we began absolute scoping them as well. For example:

include ::profiles::sometech::foo

or

::profiles::sometype { 'somename' : }

Since we've moved on from older versions of puppet and when I see code examples either on the module forge or in forums, I almost never see absolute scoping anymore in Puppet code. I know that the `$facts` global variable is the preferred way to retrieve structured facts (as opposed to the legacy identifiers). But, I haven't seen any guidance on other structures.

So, my question is a stylistic one- has this practice fallen out of favor? Is it preferred to use a more implicit scope (after all, in the examples above, I'd only get into trouble if I have yet another "profiles" named object within profiles before I'd see any accidental variable shadowing). I've reviewed the current puppet style guide [here](https://puppet.com/docs/puppet/5.5/style_guide.html) and haven't found any guidance one way or the other on use of double colons for defined types or classes. Any clarification on preferred usage would be much appreciated.

Show more