Tuesday, October 30, 2012

Struggling with Scala as a DSL

Scala was created to be a Scaleable Language.  I'm trying to figure out how well Scala has delivered on this promise.  To me, a language is scalable if it is useful for creating Domain-Specific programming languages (DSL's).  I've been going through examples and trying things on my own.  Here is a good example:  http://debasishg.blogspot.com/2008/05/designing-internal-dsls-in-scala.html

Thursday, October 25, 2012

ScalaTest is Awesome

I've been test-driving Java with JUnit and TestNG for about four years.  I've always hated that your test names are dictated by the rules of naming functions.  This yields some long and awkward function names such as:

@Test public void translatingDocumentToSpanishShouldConvertCatToGato() {...}
@Test public void givenTextIsCatAndLangIsSpanish_whenTranslate_thenReturnGato() {...}
Since Scala allows you to have anonymous functions and allows you to create Domain-Specific Languages, the makers of ScalaTest have come up with multiple solutions to cleaning up your ugly xUnit test suites.
Here is an example using Jasmine-style syntax:
describe("Translating from English to Spanish") {

    it("should translate [Cat] to [Gato]") {...}

  }
 
Here is an example using Cucmber-sytle syntax:


feature("Translate text from English to Spanish") {
 
    info("As a student who speaks English as a 2nd language")
    info("I want to be able to translate English to Spanish")
    info("So that I can make sure I understand my reading")
 
    scenario("translate simple single word") {
 
      given("[cat] in my English text") {...}
      when("I choose to translate to Spanish") {...}
      then("I see [gato]"){...}
    }
 
  }

You may ask "Why should we care if a test is pretty or ugly? Our customers are not asking for pretty tests!". The reason is that if you employ software developers, you are paying 80% of their salary for reading and understanding code, and only 20% for writing code. If you have a developer that can type 40 words-per-minute, and they are giving you 8 hours a day writing code at 40 WPM, that's not the developer you want in your shop.

There is much more. Note that ScalaTest can test Java code as well as Scala code. Visit http://scalatest.org/ to learn more.

Friday, October 19, 2012

Challenge: One Hour with Mozilla Badges


badges.pngChallenge:  One Hour with Mozilla Badges

persona1.png

Spend one hour (or hopefully less) to learn about Mozilla Badges


Part 1:  Earn your first badge

Go to Mozilla badges at http://openbadges.org/en-US/
Click "get started" to earn your first badge

Part 2:  Earn your first badge on P2PU.org

Go to p2pu.org
Create an account (Make sure you confirm your email address so you can post)
Find the challenge "Introduce Yourself"
Take 30 minutes to an hour to complete the challenge.

Part 3:  Send your P2PU badges to your Mozilla backpack

Select "My Settings" from the drop-down under your name on P2PU.org
Click on "Share Badges" and click "Send"
Confirm adding your P2PU badges to your Mozilla backpack
Confirm your badges at http://openbadges.org/en-US/ (visit your Mozilla Badge Backpack)



Thursday, October 18, 2012

Code Jam at Work Today

I work at Cengage Learning.  One of our products is Mind Tap.  I've never worked on Mind Tap, but was able to participate in a Code Jam today.  Mind Tap supports Mind Apps, which are web applications that live outside of the core product, written with whatever technology the creator sees fit.  You include a URL to a JSON response that allows your application to be registered to Mind Tap.  We are actively looking for people who want to develop Mind Apps for Mind Tap.

I was part of a small team that choose to create a Mind App using Play Framework and Heroku.  It's cool, because it's a solution that we don't normally use.  We had five hours to create an application and integrate it into Mind Tap.

Our idea was to allow students to highlight a work in their lesson, then search that word in Fox News and The Onion.  We randomly picked one article from one of these sources, and asked the user to guess the source -- Fox News or The Onion.

Here is our final product (stand-alone, before the mind tap integration.  Will it live to see production?  Time will tell.

Wednesday, October 17, 2012

Hello World


I've been writing code for several decades now.  Lots of Java since the days of Java 1.1.  Before that, lots of C++.  Previously C, different dialects of Basic, assembler, pascal, etc.  Currently playing with Scala and object-oriented JavaScript.  I like JSON and JQuery.