FXML 文档命名约定
FXML document naming convention
在创建 FXML 文件或 XML 时,是否有我应该遵循的特定文档命名约定一般文件?我一直在关注 Oracle 提供的一些教程并得出 FXML 文件应该以 prefix
开头的结论
fxml
并以 后缀
结尾
view
因此,示例 FXML 文档看起来像
fxml_tableview.fxml
教程来源:http://docs.oracle.com/javafx/2/fxml_get_started/jfxpub-fxml_get_started.htm
具体页面:http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm
我刚刚在博文中介绍了我可以推荐的命名约定:
If "mypackage.<name>.java" loads a FXML file, then the FXML file
should be in the same package and be named "<name>.fxml".
一个优点是,当遵循此命名约定时,很容易看出哪个 FXML 加载器/fx:root-控制器和 FXML 文件属于一起。
另一个好处是可以简化加载代码。
您可以在此处阅读更多相关信息:http://puces-blog.blogspot.ch/2015/03/drombler-commons-conventions-to.html
关于 JavaFX 的 CERN 论文包括一个关于命名约定的部分。
Both, the FXML file and its controller should have
names allowing an easy identification that they belong to
the same view, without looking at their content.
In fact, JavaFX introduced a naming convention for
nested controllers. For instance, if an included view
ID is dialog
, then the corresponding controller can be
referenced as dialogController
. This convention could be
extended to other entities associated with a single view
such as model, service, CSS or resource bundle properties
file. In addition, all files related to a single view could be
placed in a dedicated Java package, named after the view.
In such case the content of every package would be similar:
• [view_name].fxml
• [view_name]Controller.java
• [view_name]Model.java
• [view_name]Service.java
• [view_name].css
• [view_name].properties
Note that only the FXML, controller and in most cases
also model files are be present, while CSS, resource bundle and any additional files are optional. Such convention is very easy to remember. With a
glimpse of an eye one can recognize all the elements and
have a good idea what is inside.
来源:Best Practices For Efficient Development Of JavaFX Applications
在创建 FXML 文件或 XML 时,是否有我应该遵循的特定文档命名约定一般文件?我一直在关注 Oracle 提供的一些教程并得出 FXML 文件应该以 prefix
开头的结论fxml
并以 后缀
结尾view
因此,示例 FXML 文档看起来像
fxml_tableview.fxml
教程来源:http://docs.oracle.com/javafx/2/fxml_get_started/jfxpub-fxml_get_started.htm 具体页面:http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm
我刚刚在博文中介绍了我可以推荐的命名约定:
If "mypackage.<name>.java" loads a FXML file, then the FXML file should be in the same package and be named "<name>.fxml".
一个优点是,当遵循此命名约定时,很容易看出哪个 FXML 加载器/fx:root-控制器和 FXML 文件属于一起。
另一个好处是可以简化加载代码。
您可以在此处阅读更多相关信息:http://puces-blog.blogspot.ch/2015/03/drombler-commons-conventions-to.html
关于 JavaFX 的 CERN 论文包括一个关于命名约定的部分。
Both, the FXML file and its controller should have names allowing an easy identification that they belong to the same view, without looking at their content. In fact, JavaFX introduced a naming convention for nested controllers. For instance, if an included view ID is
dialog
, then the corresponding controller can be referenced asdialogController
. This convention could be extended to other entities associated with a single view such as model, service, CSS or resource bundle properties file. In addition, all files related to a single view could be placed in a dedicated Java package, named after the view. In such case the content of every package would be similar:
• [view_name].fxml
• [view_name]Controller.java
• [view_name]Model.java
• [view_name]Service.java
• [view_name].css
• [view_name].properties
Note that only the FXML, controller and in most cases also model files are be present, while CSS, resource bundle and any additional files are optional. Such convention is very easy to remember. With a glimpse of an eye one can recognize all the elements and have a good idea what is inside.
来源:Best Practices For Efficient Development Of JavaFX Applications