One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend !...

11
One-liners are your friend: increasing productivity with Scala [email protected]

Transcript of One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend !...

Page 1: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

One-liners are your friend: increasing productivity with Scala

[email protected]

Page 2: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

One-liners are your friend

Ø  Less code shouldn’t decrease readibility: Ø  List(1,2,3,4,5).filter { theCurrentNumber => theCurrentNumber < 4 } Ø  List(1,2,3,4,5).filter { number => number < 4 } Ø  List(1,2,3,4,5).filter { n => n < 4 } Ø  List(1,2,3,4,5).filter { _ < 4 }

Ø  Our definition: short statements, possibly on 2 lines J

Page 3: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Possible setup for Enterprise Development

JAVA SCALA Domain Model

POJOs

Case classes

REST API - Server - Client

HttpClient, …

Dispatch, …

Asynchronous, concurrent

Futures, Threads and Locks

Futures Dataflow concurrency

Page ♣ 3

Page 4: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

COUPONS Service

GET

http://localhost:8086/deals

Page 5: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

REPL (Read-Eval-Print Loop)

Page 6: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Summary of Map/Reduce as a runnable program…

Page 7: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

… as a Tweetable Oneliner

Page 8: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Akka dataflow concurrency

Page 9: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Additional Links

§ Dispatch: http://dispatch.databinder.net/Dispatch.html

§ Akka: http://www.typesafe.com/technology/akka

§ Videos online from Jfokus 2009-2012, ScalaDays, Scala eXchange, NEScala…

§  InfoQ article (by me): “An Introduction to Scala for Java Developers”

http://www.infoq.com/articles/scala-for-java-devs

§ Fast Track to Scala Course @DevCode, Stockholm

Page 10: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Do You Have Any Questions?

Page 11: One-liners are your friend: increasing productivity with Scala€¦ · One-liners are your friend ! Less code shouldn’t decrease readibility: ! List(1,2,3,4,5).filter { theCurrentNumber

Extra: Testing with Unfiltered