我已閱讀下面的討論:在什麼情況下靜態方法是一種好的做法?
Should private helper methods be static if they can be static,並且
Should all methods be static if their class has no member variables
看來,一般人會接受靜態方法,但都有點懷疑它,有以下兩個原因:
- 他們很難測試。
- 他們違反了OO原則。 (他們 是功能,而不是方法,說 人。)
而且最能接受的靜態方法私有靜態的。但是爲什麼靜態方法完全存在,以及在什麼情況下它們是被優先採用的首要任務?
這個討論也很有用:什麼時候不在Java中使用static關鍵字http://stackoverflow.com/questions/1766715/when-not-to-use-the-static-keyword-in-java – 2013-02-12 13:33:23