[英]What is the naming convention for side effectful functions in Java?
差不多的頭銜。 我需要區分可怕的事物和安全的事物,而不必查看功能體內。 Java中的標准是什么? 我不能放“!” 在函數名稱中。
例:
// convenient when you don't want to update the reference in the objects that were using
// param
BiFunction<T,U,T> mutableTransformation = (param,operand) -> {
//... do operations that alter param using operand
return param;
}
通常,任何以set
開頭的方法都有副作用。 根據最近的慣例(自Java 8開始),名稱中帶有of
或with
方法是無副作用的。 示例是java.time
包中的新日期/時間類。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.