java - Java package naming when domain and app name are the same
问题描述
I'm curious about best practices around Java package naming when the domain name and the class name would be the same.
For example, if I am creating a new android app called Foo and my domain is foo.com
The java package name would be
com.foo.foo
correct?
Is there a better way to name it or am I overthinking this?
解决方案
the convention is always
domain.domainname.package[.subpackage].Class
(where subpackage
is optional). The goal is to have a unique namespace for each project, to avoid namespace collisions, so shortening it is not a good idea.
to answer your question: com.foo.foo
is a correct name if the second foo
is the name of your project. if this project now contained a class Bar
, the path would be com.foo.foo.Bar
.
推荐阅读
- node.js - 使用 Express 覆盖所有响应标头
- ios - Xcode 尝试在未从模拟器卸载的情况下运行应用程序时显示错误(多配置文件)
- latex - 使用 gnuplot,如何获取具有画布大小的 PDF,包括文本?
- javascript - JavaScript 中的函数是如何实现固有异步的
- json - 使用 powershell 编辑 Json
- python - Python 日志记录失败
- python - 根据 NumPy 中的非标准化对数概率从集合中采样
- python - 网页抓取时如何登录网站
- python - Python 中的粗体注释。相当于 Python 中的 MATLAB '%%'
- java - 将我的文件打印到控制台时遇到问题