Why Do Package Names Start With com. In Actionscript 3?

Question:

Why do package names start with com. in Actionscript 3?

By the way, I’m guessing you already know that package names map to folder names. E.g. an as3 source file in the package com.example must be under the folder example, which in turn must be under the folder com..

Answer:

Package names do not have to begin with com. However, it is the convention to do so. E.g. com.thebestcompany.thebestproduct

What is the significance of com? Well, the package name is simply a domain name reversed. E.g com.helloworlder.utils

The domain name technically does not have to exist but you should own it. Obviously never use someone else’s domain name!! That’s just rude. It is standard practice to use a domain name because it helps to guarantee that your package names don’t collide with the names of someone else’s package on the other side of the world.

If I release some AS3 code that creates popup windows, I may place the code in a package called com.helloworlder.utils.popupwindow and not simply popupwindow

Likewise, if I download some third party code to use in my own project I’d expect their code to be packaged properly. E.g. com.goodbyeworld.utils.modalwindow. Then, I can just place their goodbyeworld folder under by own com folder.

Just as importantly, putting your as3 files into packages helps you think about how to organize the files. Often people place all files (their own and 3rd party code) under one folder! The advice is - don’t.


  1. Thanks, I’ve always wondered why package names started with “com” and finally decided to Google it, which brought me here thankfully.

    Pretty clever idea, but I’d imagine this wouldn’t work for developers creating their own engine / framework so to speak, and want to give it a name. The engine wouldn’t necessarily share the same name as the developers domain, so the engine name would have to replace the part after “com.” and the “com.” omitted as well, if the domain doesn’t exist.

  1. There are no trackbacks for this post yet.

Leave a Reply


Easy AdSense by Unreal