jjj
jjj

Reputation: 245

grails naming convention

Being new to Grails, Groovy, and even Java, I was wondering why many Grails developers use the naming convention such as

com.{projectName}.{className}

What is the point of organizing them first by the com (what does it even mean?), and then project name (when it's already within the project folder)?

Upvotes: 1

Views: 1605

Answers (2)

Romski
Romski

Reputation: 1942

In Java, the intention is to have code play nicely when it may have different authors in different companies. For example, I write an application that has the notion of a User and I assign it to the default package. I need to make use of your framework/library and it too has the notion of a User assigned to the default package. Which User should be loaded and when should it be used? By packaging based on a company's reversed domain name, we can organise User objects based on each company's definition and use, and our code can co-exist.

Upvotes: 0

Mike Park
Mike Park

Reputation: 10931

More of a Java standard. See http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

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.

Upvotes: 6

Related Questions