Scala Principles in a Nutshell (Part III)

Let’s say that we have the following code in Scala (too similar to Java, btw): def isGoodEnough(inc:Int,x:Int)=x>inc; def increasePosition(inc:Int,x:Int):Int= if (isGoodEnough(inc,x)) return x+inc; else return x; def increasePositionByOne(x: Int) ={ return increasePosition(1,x); } Now we’ll transform that piece of code into something more Scala-ish 😀 First of all, in Scala Read more…

The Builder Pattern

What is this pattern for? This pattern is used when it’s necessary to isolate the construction of a complex object and at the same time have more than one representation. Featuring: The Client: They want an application with a specific construction. In this case, they want an application written in Read more…