Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention for packages and projects

There was a discussion about that here in SO but I still have a question about that topic, though. So, a simple question: what is a naming convention for projects in Scala? Is it "my_new_project", "myNewProject", "my-new-project", "MyNewProject" or "mynewproject"? And the same question for packages.

like image 374
Incerteza Avatar asked Nov 08 '13 12:11

Incerteza


People also ask

What convention is used in naming classes?

Class names should be nouns in UpperCamelCase , with the first letter of every word capitalised. Use whole words – avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).

Why are packages named com?

Generally we android developer having practice to decide package name based on the domain name of a particular company. For example: Domain name: sun.com => Root package name something like : com.

What is the naming convention for project name in Java?

Java uses CamelCase as a practice for writing names of methods, variables, classes, packages, and constants.

Can package name have underscore?

Why does Android Studio warns me that my app's package name should not contain underscores, despite the fact that the docs here states that we can use underscore? Also here, it is written that all characters must be alphanumeric or an underscore [a-zA-Z0-9_].

What are the conventions of package names?

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 the importance of naming conventions in software development?

Naming conventions lead to predictability and discoverability. A common naming convention, coupled with a consistent project structure, makes it easier to find files in a project. In short, naming convention is so important that Phil Karlton is said to have said,

Can I have a single naming convention for a project?

When a project is written in multiple languages, it's not possible to have a single naming convention. For each language, adopt the naming convention prevalent in that language. Another example is when you're using a third-party library.

What is the best way to name a package?

Aside from that, the general rule of thumb is - all your names should be descriptive: for package - what common functionality (goal) do all classes within that package provide (aim to achieve) +1 Use Sun's naming conventions, they are the de-facto standard that almost everybody seems to use for Java.


3 Answers

Packages follow com.mycompany.myproject reversed-URL style. There is no naming convention for project names. Many people prefer all lower case with hyphenation like scala-foo. I prefer capitalised camel-case like ScalaFoo. It's a matter of taste. I have not seen scalaFoo as a project name convention, also underscore is not used (I think that's C or Python style?)


Like in the earlier days of Java, where almost every project begins with a J, there are a lot of projects beginning with scala. While I think this makes sense for porting existing libraries, I came to think that you should probably not call your project ScalaFoo or ScFoo but just Foo unless there is a specific reason to highlight the fact it's written in Scala.


You may take a look at the community libraries wiki to sense the taste for project names.

like image 190
0__ Avatar answered Oct 17 '22 06:10

0__


I don't know if there is a specific naming convention for projects in Scala, but usually the Java convention is used, so: - thisIsAVariable (all but first word initial letter uppercase aka camelCase) - ThisIsAClass (all initial letters uppercase aka PascalCase) - com.example.www (reversed url for packages)

I've seen both camelCase and PascalCase for naming projects in Java, but I prefer PascalCase!

like image 28
Vincenzo Maggio Avatar answered Oct 17 '22 05:10

Vincenzo Maggio


For projects, I have seen many people use my-new-project or MyNewProject frequently. I personally prefer MyNewProject. I have researched your question a lot and haven't found any set conventions for project names. I do believe on GitHub a lot of repositories use my-new-project and almost appears like it's their own convention for repository names.

For packages, the convention is to either use a company domain address or personal domain address with all lowercase letters in reverse order style: com.company.packagename.

Hope that helps!

Brady

like image 43
bradylange Avatar answered Oct 17 '22 06:10

bradylange