Scala · Tutorial

How to use Case Classes in Scala

Scala has adopted many concepts from other functional programming languages: higher-order functions from Haskell, actors model from Erlang, futures from Clojure, etc. However, Scala has also introduced new tools in the functional programming world: case classes is one of them. Case classes are a special type of classes, as the compiler automatically adds some useful… Continue reading How to use Case Classes in Scala


Akka Actors: Best Practices

Actors are components of message-passing systems that are particularly popular these days. They make concurrency a lot easier to understand compared to the traditional thread-monitor-lock model. An actor is a thread-like program that run independently from other actors. It has a mailbox to receive messages from other actors, where each message represents a task to… Continue reading Akka Actors: Best Practices


RESTful now more important than ever.

REST APIs are becoming more and more popular: they allow horizontal scalability, they are flexible to change and easy to use without the need of detailed documentation. However, some APIs claim to be RESTful when they are not. This is mainly for two reasons: - We don’t always have a clear idea of what RESTful means, we just associate… Continue reading RESTful now more important than ever.

Scala · Tutorial

Stateful objects: use them to lie!

Sometimes we want to hide/protect our variables — the classic concept of encapsulation in object oriented programming. We’d like to write a Scala class to manage someone’s age. In particular, we’d like to: - lie on our age if we are not teens anymore (you never know!) - put some validation to avoid negative age values Our… Continue reading Stateful objects: use them to lie!


Super Powers to Qualified Access Modifiers

Scala uses access modifiers quite differently from Java. Let’s see what the differences are and why qualified access modifiers are so powerful in Scala. default access modifier Scala >> public Java >> protected While in Scala the public keyword doesn’t exist, Java allows you to explicitly use the keyword protected as you please. private Scala >> accessible from a class and its companion… Continue reading Super Powers to Qualified Access Modifiers