2014-03-01 24 views
1

在Java中我使用的模板domain.company.project.module.ets把裏面長信息名包中的類和用於像名稱:如何組織scala項目內部的類?

  • ch.qos.logback.classic.net
  • org.hibernate.cache
  • com.google.common.collect

但在阿卡的來源和SBT項目有很多的內部包中的類s的簡單的名稱:

  • akka.actor
  • SBT

而且這還不是全部。類內有很多類。通過課程,我也指所有可能組合中的對象和特徵。特質裏面有特質,班內特質等。但是嵌套層次總是是1 (或者我應該說2?)

顯然,還有另一種類型組織的方法。我想知道是否可以給我一個關於如何在scala中命名包以及何時將類放入對方的提示?

回答

2

您好,我會推薦您閱讀scala的chater 7 for imatient是免費的:http://typesafe.com/resources/free-books

作爲總結的關鍵點,如賽義德在書:

- Packages nest just like inner classes. 
- Package paths are not absolute. 
- A chain x.y.z in a package clause leaves the intermediate packages x and x.y invisible. 
- Package statements without braces at the top of the file extend to the entire file. 
- A package object can hold functions and variables. 
- Import statements can import packages, classes, and objects. 
- Import statements can be anywhere. 
- Import statements can rename and hide members. 
- java.lang, scala, and Predef are always imported.