Builder Pattern (Scala, Java) SparkSession uses builder patterns
…in which you provide a constructor with only the required parameters, another with a single optional parameter, a third with two optional parameters, and so on, culminating in a constructor with all the optional parameters.
@Builder annotation - if applied on a class (POJO) will create its Builder class automatically
Support @Builder on Person class will create PersonBuilder class ad you can set it as below
Person.builder().firstName("Adam").lastName("Savage") .city("San Francisco").jobTitle("TV Personality").build();
Tail-Recursion (
https://www.geeksforgeeks.org/tail-recursion-in-scala/
https://www.scala-exercises.org/scala_tutorial/tail_recursion
Example: GCD aka GCF https://www.khanacademy.org/math/cc-sixth-grade-math/cc-6th-factors-and-multiples/cc-6th-gcf/v/greatest-common-divisor
Monad
Closures
Trait
List manipulation
var myList = List.empty[String]
myList :+= "sree"
myList
res2: List[String] = List(sree)
Immutable by design - helps with concurrent programming
Option -
Yield - produces a value for each iteration
Null, Nil, None, Nothing
Null - absense of value
Nil - end of list
None - value of an Option which has no value in it
Nothing - lowest type in the entire type system (Method which throws exception returns Nothing as the return type; all values under val, var falls under this)
Extractor Object - with unapply method (match the value and take it apart)
Pattern matching - case statement
def matchValue(x: Int): String = x match {
case 1 => "One"
case 2 => "Two"
case _ => "many"
}
Queue val emptyQ = new scala.collection.mutable.Queue[Int]