I'm trying to build a ETL-type module in scala for Spark. I have a base class transformer,
trait transformer{
def transformer()
}
However then I extend this base class to two more types single return and multi return,
trait UnaryReturnTransformer extends transformer{
def inPorts()
def outPorts()
def setExpressions()
}
trait MultiReturnTransformer extends transformer{
def inPorts()
def outPorts()
def setExpressions()
}
Now, the actual implementation say, lookup transformer,
class LookupTransformer extends UnaryReturnTransformer{
//set local variables
//override functions
override def inports(df:DataFrane):
}
Is it better to return the class itself so that we could chain the code, Eg,
new LookupTransformer().inports().setExpression().transform().Outports()
or make them as
val x=new LookupTransformer()
x.inports()
x.setExpression()
x.transform()
val ret=x.outPorts()
This seems more like a design question to me and It would be great to know what is the best practice to design such a system.
Thanks!
Aucun commentaire:
Enregistrer un commentaire