Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why use com.company.project structure? [closed]

Does anyone know of the practical reasons for the com.company.project package structure and why it has become the de-facto standard?

Does anyone actually store everything in a folder-structure that directly reflects this package structure? (this is coming from an Actionscript perspective, btw)

like image 495
hamishtaplin Avatar asked Aug 20 '10 09:08

hamishtaplin


People also ask

What is the meaning of package com company in Java?

It is not mandatory to use com. company, you can use your own package name. Package is used to organize classes belonging to the same category or similar functionality. Classes can be downloaded faster as a group rather than one at a time.

What com company means?

A dot-com company, or simply a dot-com (alternatively rendered dot.com, dot com, dotcom or .com), is a company that does most of its business on the Internet, usually through a website on the World Wide Web that uses the popular top-level domain ".com".

What should I name my Java package?

Naming Conventions Package names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, com. example. mypackage for a package named mypackage created by a programmer at example.com .

What is package by feature?

Package-by-feature uses packages to reflect the feature set. It tries to place all items related to a single feature (and only that feature) into a single directory/package. This results in packages with high cohesion and high modularity, and with minimal coupling between packages.


3 Answers

Preventing name-clashes is a rather practical reason for package structures like this. If you're using real domain names that you own and everybody else uses their package names by the same role, clashes are highly unlikely.

Esp. in the Java world this is "expected behaviour". It also kind of helps if you want to find documentation for a legacy library you're using that no one can remember anymore where it was coming from ;-)

Regarding storing files in such a package structure: In the Java world packages are effectively folders (or paths within a .jar file) so: Yes, quite a few people do store their files that way.

Another practical advantage of such a structure is, that you always know if some library was developed in-house or not.

like image 92
Horst Gutmann Avatar answered Nov 03 '22 02:11

Horst Gutmann


I often skip the com. as even small orgs have several TLDs, but definitely useful to have the owner's name in the namespace, so when you start onboarding third-party libraries, you don't have namespace clashes.

Just think how many Utility or Logging namespaces there would be around, here at least we have Foo.Logging and Bar.Logging, and the dev can alias one namespace away :)

like image 28
Florian Doyon Avatar answered Nov 03 '22 01:11

Florian Doyon


If you start with a domain name you own, expressed backwards, then it is only after that point that you can clash with anyone else following the same structure, as nobody else owns that domain name.

It's only used on some platforms.

like image 26
Jon Hanna Avatar answered Nov 03 '22 00:11

Jon Hanna