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.
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).
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.
Java uses CamelCase as a practice for writing names of methods, variables, classes, packages, and constants.
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_].
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.
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,
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.
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.
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.
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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With