If you want to share your code to handle local and abstract code, you can move your lambdas / anaonymous functions that you pass to map / flatMap to named functions and reuse them.
If you want to reuse your logic to order maps / flatMaps / etc., you can also create implicit conversions between RDD and Seq into a custom attribute that has only common functions, but implicit conversions can become quite confusing, and I really I donβt think this is a good idea (but you could do it if you disagree with me :)).
source share