Blogs

Key and Peele East/West College Bowl, list of names

I don't watch much television, but some friends keep sending me URLs to Key and Peele videos, including the recent East/West College Bowl skit.

As we sent emails back and forth, laughing about the names they came up with and which one we'd want to be, I decided to jot down the names they used in the video, and without any further ado, here's a list of the names.

Scala REPL - java.lang.OutOfMemoryError: Java heap space error

I just got a “java.lang.OutOfMemoryError: Java heap space error” when trying to use the Scala REPL to analyze a large XML dataset:

Paraprosdokians

From an email today:

A Scala Null Object example

A Null Object is an object that extends a base type with a null or neutral behavior. Here’s the Scala version of the Java example Wikipedia uses to demonstrate this:

trait Animal {
  def makeSound()
}

class Dog extends Animal {
  def makeSound() { println("woof") }
}

class NullAnimal extends Animal {
  def makeSound() {}
}

As you can imagine, later in your application you might have some code like this:

Is Scala DICEE?

If you’ve never heard of the term DICEE, it was coined by Guy Kawasaki. Mr. Kawasaki was a developer evangelist for the original Macintosh team in the 1980s, and used the term in at least one subsequent book to refer to great products.

“DICEE” is an acronym that stands for Deep, Indulgent, Complete, Elegant, and Emotive:

Scala version of Collective Intelligence Euclidean distance algorithm

While reading the excellent book, Programming Collective Intelligence recently, I decided to code up the first algorithm in the book using Scala instead of Python (which the book uses).

Scala Option, Some, None syntax examples

Today I’m sharing some examples of the Scala Option/Some/None syntax. These examples will show how to use an Option for the var fields in a Scala class. Then I’ll show how to set those Option fields, and then get the values from the Option fields.

To get started, we’ll need a little case class to represent an Address:

Some Scala Exception allCatch examples

At the time of this writing there aren’t many examples of the Scala Exception object allCatch method to be found, so I thought I’d share some examples here.

In each example I first show the "success" case, and then show the "failure" case. Other than that, I won’t explain these, but hopefully seeing them in the REPL will be enough to get you pointed in the right direction:

Five reasons Ron Johnson failed at JC Penney

From a Time article, five reasons Ron Johnson failed at JC Penney:

  1. He misread what shoppers want
  2. He didn’t test ideas in advance
  3. He alienated core customers
  4. He totally misread the JC Penney brand
  5. He didn’t seem to like or respect JC Penney

One thing missing in the main story that shows up in the comments: He never bothered to move to Texas, where Penney’s corporate headquarters are.

The full story: http://goo.gl/m394g

How to declare, set, and use Option, Some, and None fields in Scala

Again not much time for a discussion today, but if you’re looking for an example of how to declare, set, and use Option fields in Scala, I hope this source code is helpful:

Syndicate content