Home > Software engineering >  What is this dot separation naming convention?
What is this dot separation naming convention?

Time:10-09

I'm following a tutorial to create a launchd job that runs a simple hello-world script.

The instructions require the creation of a plist file and suggest the following filename: com.demo.daemon.plist

What are the dot-separated elements in this naming convention? Is there some significance to it?

I also looked at the current active jobs and saw that all the services more or less adhere to this standard.

❯ launchctl list
PID Status  Label
-   0   com.apple.SafariHistoryServiceAgent
61509   -9  com.apple.progressd
95725   0   application.com.adobe.CCLibrary.14385130.14385136
48884   -9  com.apple.cloudphotod
84600   0   application.com.sublimetext.4.1845546.1845552
2156    0   com.apple.Finder
...

CodePudding user response:

This is reverse domain name notation. The basic idea is to avoid naming conflicts by starting each name with the item owner's domain name, in reverse order. For instance, Apple Corp owns the apple.com domain, and therefore can use "com.apple." as a prefix and not worry it'll conflict with anyone else's identifiers. Similarly, Cambridge University owns cam.ac.uk, so they could use the "uk.ac.cam." prefix.

This doesn't work very well for anyone who doesn't own a domain name. Using valid-looking prefixes with a domain you don't own is common, but IMO a bad idea. It superficially appears to follow the convention, but actually completely violates it. For instance, the demo.com domain is registered to MarkMonitor Inc., so by convention nobody but MarkMonitor should be using "com.demo." as a prefix.

I tend to use "local." as a prefix (e.g. the label local.this-here-daemon, which would be in a file named local.this-here-daemon.plist). The actual "local" top-level domain is reserved for local assignment via multicast DNS, and therefore not available for actual ownership. So I while might conflict with someone else using the same convention, I at least won't be stepping on namespace that's specifically owned by someone else.

(The domains example.com, example.net, example.org, and the example top-level domain are all reserved for use in documentation, so I'd consider "com.example.", "net.example.", "org.example.", and "example." to be good prefixes for use in code examples... but not really appropriate for anything you're actually going to install and run.)

  • Related