我在 Scala 中有许多无状态对象,我想将它们组合成一个 API - 一种外观如下:
object tools {
// List all methods in toolA
// List all methods in toolB
// List all methods in toolC
}
object ToolA { ... }
object ToolB { ... }
object ToolC { ... }
显然,维护列表很烦人,因为,和中tools
的方法变化很大。A/B/C 中没有状态,也没有设置参数。ToolA
ToolB
ToolC
有什么说法…… “make tools
contains the set of all the methods in ToolA
, ToolB
, and ToolC
”?