Marc Knaup
06/04/2021, 3:05 PMfun interface SomeLongTypeNameFactory {
fun create(): SomeLongTypeName
}
Con: Causes conflict if a class implements multiple factories.
2️⃣ Function name explicitly mentions type
fun interface SomeLongTypeNameFactory {
fun createSomeLongTypeName(): SomeLongTypeName
}
Con: Long & repetitive.
3️⃣ Other convention (add comment)Michael Böiers
06/04/2021, 3:19 PMmapOf()
or mutableListOf()
. I haven’t yet seen factory interfaces … I guess for those I would opt for createX()
, and make X
as short as possible.Marc Knaup
06/04/2021, 3:30 PMMichael Böiers
06/04/2021, 3:55 PMMichael Böiers
06/04/2021, 3:57 PMMarc Knaup
06/04/2021, 3:58 PMMarc Knaup
06/04/2021, 3:58 PMMarc Knaup
06/04/2021, 3:59 PMdave08
06/05/2021, 6:27 PMMichael Böiers
06/05/2021, 8:32 PMMarc Knaup
06/06/2021, 3:55 PMoperator fun invoke()
would also be variant 1️⃣ along with its potential for conflict. Just with a different function name.dave08
06/06/2021, 3:56 PM