在Java中編寫實用程序類時,有哪些遵循的指導原則?Java中實用程序類的命名約定
包裝應該是「util」還是「utils」?它是ClassUtil還是ClassUtils?什麼時候上課是「助手」還是「實用」?實用程序或公用程序?或者你使用它們的混合物?
標準Java庫同時使用的Utils和實用程序:
- javax.swing.Utilities
- javax.print.attribute.AttributeSetUtilities中
- javax.swing.plaf.basic.BasicGraphicsUtils
Apache使用各種Util和Utils,雖然主要是Utils:
- org.apache.commons.modeler.util.DomUtil
- org.apache.commons.modeler.util.IntrospectionUtils
- org.apache.commons.io.FileSystemUtils
- org.apache.lucene.wordnet .AnalyzerUtil
- org.apache.lucene.util.ArrayUtil
- org.apache.lucene.xmlparser.DOMUtils
Spring使用了很多助手和utils的類:
- org.springframework.web.util.UrlPathHelper
- org.springframework.core.ReflectiveVisitorHelper
- org.springframework.core.NestedExceptionUtils
- org.springframework.util.NumberUtils
那麼,你如何命名你的公用事業類?
和第四號的IV :-) - 但是*運費*,*貨運費*,和* frght *之間的差異是什麼? – KajMagnus 2012-03-04 08:57:06
@KayMagnus這篇文章是在一年前,但據我記得,其中之一是目前的運費成本的記錄,在改變訂單的內容,因此可能的運費成本;另一個是從一個表中抽取的標準運費;第三種是在某些特殊情況下使用的計算成本,如海外裝運。至少爲什麼他們至少不能打電話給他們,比如說「currFreight」,「stdFreight」和「calcFreight」。那至少會給出一個提示。 – Jay 2012-03-07 22:02:13
好的,感謝您的解釋:-)一個有趣的怪異代碼示例,我認爲 – KajMagnus 2012-03-08 07:28:35