【发布时间】:2019-10-13 18:22:21
【问题描述】:
Scala 中函数返回结果包装在 Future 中的命名约定是什么?我见过这样的代码:
getResult
getResultF
getResultFtr
甚至
getResultFuture
如果没有特定的约定那么我想知道更多的做法。
【问题讨论】:
-
不要将
getX之类的东西用于需要时间的东西。使用fetchX: Future[X]。使用getX进行长时间通话并不是一个好主意。所以请改用fetchX、computeX、calculateX、generateX。 -
无特定约定
-
我会使用
getResultFuture,但这只是个人喜好AFAIK。我从来没有就命名 Futures 的“正确”方式达成共识。
标签: scala naming-conventions future