For example in Objective-C, where class extensions are direct language construct, we do:
in filed named NSArray+FKBinarySearch.h:
@interface NSArray (FKBinarySearch)
// ...
@end
Do you name your extension classes like:
implicit class IndexedSeqBinarySearch[A](seq: IndexedSeq[A]) {
// ...
}
For example scalaz calls makes extensions classes with suffix Ops
: BooleanOps or even extending their own traits FoldableOps
Yet Ops
feels too general, OTOH there are packages. Also Ops
in scalaz case contains everything.
In Programming in Scala in "Chapter 21 · Implicit Conversions and Parameters" -> "Naming an implicit conversion." it is said:
Implicit conversions can have arbitrary names. The name of an implicit conversion matters only in two situations: if you want to write it explicitly in a method application, and for determining which implicit conversions are available at any place in the program.
In Programming Scala "Chapter 5: Implicits" -> "Wise Use of Implicits" it is said:
One way to improve implicits visibility is to adopt the practice of putting implicit values in a special package named implicits or an object named Implicits.
Using implicit class is like using implicit method, but in case of class its primary constructor is involved. And if you look at Scala implicit conversion methods results you can find something like:
- wrapString(s: String): WrappedString
- genericArrayOps[T](xs: Array[T]): ArrayOps[T]
In my opinion inside Implicits
object for your implicit class name the following can be used:
- xOps
- RichX
- WrappedX
- AsX
You may choose any of them which is appropriate to your project conditions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With