差異處
這裏顯示兩個版本的差異處。
下次修改 Both sides next revision | |||
java:effective_java:lambdas_and_streams:favor_the_use_of_standard_functional_interfaces [2019/07/21 23:09] tony 建立 |
java:effective_java:lambdas_and_streams:favor_the_use_of_standard_functional_interfaces [2019/07/21 23:30] tony [Introduction & My Opinion] |
||
---|---|---|---|
行 22: | 行 22: | ||
- 基於新的functional interface可能會被廣泛使用、名稱是很重要的概念或是會使用到default method,那就可以選擇自創武功。書中是以Comparator為例。 | - 基於新的functional interface可能會被廣泛使用、名稱是很重要的概念或是會使用到default method,那就可以選擇自創武功。書中是以Comparator為例。 | ||
- 自創武功時,要記得宣告@FunctionalInterface。這可以明確告訴開發人員它的用途,也可以避免被加上不屬於這個用途的method。 | - 自創武功時,要記得宣告@FunctionalInterface。這可以明確告訴開發人員它的用途,也可以避免被加上不屬於這個用途的method。 | ||
+ | - 盡量避免在overloading method同一個位置的參數使用不同的functional interface,這容易造成client ambiguity問題。 | ||
===== Note ===== | ===== Note ===== | ||
Effective Java第三版Item 44。 | Effective Java第三版Item 44。 |