簡體   English   中英

Java中的副作用函數的命名約定是什么?

[英]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開始),名稱中帶有ofwith方法是無副作用的。 示例是java.time包中的新日期/時間類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM