Transit a name from one type to another
Transit a name from one type to another
the thing with a "good" name
the thing that will receive the "good" name
the from
parameter
Transit a name from one type to another and add a suffix
Transit a name from one type to another and add a suffix
the suffix to append
the thing with a "good" name
the thing that will receive the "good" name
the from
parameter
The purpose of
TransitName
is to improve the naming of some object created in a different scope by "transiting" the name from the outer scope to the inner scope.Consider the example below. This shows three ways of instantiating
MyModule
and returning the IO. Normally, the instance will be namedMyModule
. However, it would be better if the instance was named using the name of theval
that user provides for the returned IO.TransitName
can then be used to "transit" the name from the IO to the module:TransitName
helps library writers following the Factory Method Pattern where modules may be instantiated inside an enclosing scope. For an example of this, see how the Queue factory usesTransitName
in Decoupled.scala factory.