By spiros on September 21, 2010
In this post I’ll describe how to use sse-breaker, a small library that implements the Circuit Breaker stability design pattern in Scala. Before mentioning any sse-breaker specifics lets quickly define what is a Circuit Breaker. A Circuit Breaker is a software component that keeps track of the error rate of various operations and when the [...]
Posted in Scala | Tagged circuit-breaker, Scala, stability
By spiros on September 20, 2010
Because of Scala‘s pattern matching syntax it is really convenient to catch Throwable instead of Exception or any other exception type. Instead of writing: try { iMayHaveIllegalState.doSomething() } catch { case e: IllegalStateException => e.printStackTrace() } we can simply write: try { iMayHaveIllegalState.doSomething() } catch { case e => e.printStackTrace() } You might be tempted [...]
Posted in Scala | Tagged exceptions, Scala |
By spiros on September 20, 2010
Scala enables immutability and functional programming but it does not dictate it. As easy it is to create immutable state via a val it is equally easy to create mutable state via a var. IMHO this is a good thing since the programmer is free to choose the programming style to use according to the [...]
Posted in Scala | Tagged antipattern, Scala |
By spiros on August 22, 2010
Guice might be one of the few libraries that is easier to use in Java than it is in Scala. The main reason for this is the absence of class literals in Scala. Instead of writing Service.class in Scala we write classOf[Service] which is longer and less readable. To illustrate this lets compare two Guice [...]
Posted in Scala | Tagged guice, Scala
By spiros on December 7, 2009
While using traits in a small Scala project, I finally understood when to use self types. Self types are often characterized by Scala newbies as an incomprehensible language feature with no obvious usage. After coding with traits for a while I understood that self types are an essential information hiding tool for composing traits. I [...]
Posted in Scala | Tagged Scala, trait