Deconstructing the Cake Pattern

This article provides a technical comparison between using the cake pattern and constructor injection for doing dependency injection in Scala. I show that within a small handful of refactoring steps, we can migrate from the cake pattern to constructor injection. We lose one minor feature along the way. The lost feature is not terribly desirable anyway, and can be emulated with constructor injection if need be. In exchange, we jettison the boilerplate and the opaque nature of the cake pattern.


Catching Up: Writing Again!

So I just finished up this blog post, Just What the Heck is Amortized Constant Time Anyway?, over the last couple weeks. And I felt odd once I finally posted it, because of the total lack of personal context as to where this post is coming from. After all, it's been over a year since my previous post. So I wanted to write a quick "catching up" post, which is mostly about the fact the I am writing again!


What the Heck is Amortized Constant Time Anyway?

Effective use of the Scala Collections Library benefits from a solid understanding of the performance characteristics of the operations on a collection. In this regard, the web page Scala Collections Performance Characteristics is a valuable resource, as it summarizes the performance characteristics of various collections in easy to read charts. We see two interesting entries on these charts: effective constant time and amortized constant time. Just what do these terms mean, and how does it affect us as Scala programmers?

In this article, we will discuss amortized constant time - a performance characteristic for mutable collections such as Java's ArrayList, HashMap and HashSet. We'll address effective constant time - seen in immutable collections such as Scala's Vector, HashMap and HashSet - in a later essay.


Catching Up

It's been a long and productive summer! I wanted to take a minute to catch you up on what I've been doing since Scala Days. I went on a major job search and interviewed with a variety of companies. I landed a new job, which I feel good about, but I'll get into that later. I had the honor of writing three guest posts for the Safari Books Online Blog. And I finally put out the third monads post. In the meantime I was still at the old job, and spending a lot of quality time with my family.


Monads in Scala Part Three: Lisst[A]

We continue our Monads in Scala series by reviewing and translating the third page of the chapter on monads from the Haskell wikibook. This page takes quite an interesting view on lists, as it does not treat lists as things that you cons onto or even look things up in. It manages to treat lists nearly entirely as monadic structures. It even manages to come up with a couple of examples of using lists that only use the basic monadic operations. To view lists as things that we cons onto, we have to wait for a later page on additive monads.


Scala Days Recap and Video


I really had a blast at Scala Days this year. I met so many wonderful people, saw many wonderful talks, and had a ton of fun. I met so many great people, I can't possibly mention them all. My best memory is drinking a glass of wine at a bar with all the Scala Days attendees, when from out of the blue come Matthias Nehlsen to greet me. We have known each other on Google+ for some time, but had never met before in person. It felt like one of those Dora episodes where they all jump into the Fairy Book and go to Fairy Land.

I also got to speak to Dick Wall a bit, which was sort of a Wayne's World moment for me ("We're not worthy!"), as I used to be an avid Java Posse listener before I started writing mostly Scala. Great podcast that really helped me keep in touch with what was going on in the Java community. For Scala, I listen to the Scalawags, and I eagerly look forward to the resumption of the Scala Types podcast.

I really loved Rod Johnson's keynote. Scala poetry is a beautiful idea. I'll try to write some one day. The only point in his keynote that I question is that startups are not going to be using Scala. I don't object out of reason, but from the observation that there are many startups in the Cambridge/Boston area that are taking up Scala. There were too many great talks to start telling stories, but I won't forget asking a stupid question at Heather Miller's Pickles and Spores talk for a while. There are still many talks that I need to catch up with online. In many slots it was hard to pick between sessions!


Scripting with Scala and SBT

I wanted to write about a great experience I had with Scala and SBT today. This morning I had to write a script to convert one .csv file into another. I figured, there's no way I'm not doing this in Scala. So I sat down to write my little script. I opened up script.scala in my current directory, and started typing:

object script extends App {