Chapter 1. Why Scala?
Listing 1.1. Creating the loop construct loopTill in Scala
Listing 1.2. Finding an uppercase character in a string using Java
Listing 1.3. Finding an uppercase character in a string using Scala
Listing 1.4. Defining a Programmer class in Java
Listing 1.5. Defining a Programmer class in Scala
Listing 1.6. Counting the number of lines in a file in Ruby
Listing 1.7. Counting the number of lines in a file in Scala
Chapter 2. Getting started
Listing 2.1. breakable, break, and install functions
Listing 2.2. An ordinal class written in Java
Listing 2.3. An ordinal class in Scala
Listing 2.4. Ordinal2.scala reimplemented
Listing 2.5. Java servlet as a RESTful service
Listing 2.6. Parsing headers and parameters passed to the program
Listing 2.7. Preparing a GET request and invoking the REST service
Listing 2.8. Preparing a POST request and invoking the REST service
Chapter 3. OOP in Scala
Listing 3.1. Declaring packages using the scoping approach
Listing 3.2. Completed MongoClient
Listing 3.3. Completed MongoClient.scala
Listing 3.5. ReadOnly collection trait
Listing 3.6. Administrable and Updatable traits
Listing 3.7. Completed DB.scala
Listing 3.8. DBCollection.scala
Chapter 4. Having fun with functional data structures
Chapter 5. Functional programming
Listing 5.1. A pure implementation of an HTTP server
Listing 5.2. Kestrel combinator
Listing 5.3. Tail recursive function with @tailrec annotation
Listing 5.4. Sequencing methods by passing back the state
Listing 5.5. StateMonad in Scala
Chapter 6. Building web applications in functional style
Listing 6.1. build.sbt with Scalaz dependencies
Chapter 7. Connecting to a database
Listing 7.1. Complete weKanban build.sbt project definition
Listing 7.2. build.scala file to define a custom task
Listing 7.3. KanbanSchema with init method for database connection
Listing 7.4. Story class with validate and save methods
Listing 7.5. Complete KanbanSchema object
Listing 7.6. CreateStory view object
Listing 7.7. WeKanbanApplication with the handle method for creating a story
Listing 7.8. Complete save story in WeKanbanApplication
Listing 7.9. Implementing drag-and-drop for the weKanban board in the main.js file
Listing 7.10. Kanban board view
Chapter 8. Building scalable and extensible components
Listing 8.1. Calculator trait with abstract type member
Listing 8.2. Product finder with self type annotation
Listing 8.3. Generic ordering system with abstract type members and self type
Listing 8.4. Solution to the expression problem using PayrollSystem
Listing 8.5. Ordering system with phantom types
Chapter 9. Concurrency programming in Scala
Listing 9.2. WordCount implementation using actors
Chapter 10. Building confidence with testing
Listing 10.1. String specification for ScalaCheck
Listing 10.2. Complete EitherSpecification
Listing 10.3. Basic CalculatePriceService
Listing 10.4. JUnit test case for calculating price service (cake pattern)
Listing 10.5. Bean version of CalculatePriceService
Listing 10.6. Spring application context file
Listing 10.7. Complete unit testing using Spring dependency injection
Chapter 11. Interoperability between Scala and Java
Listing 11.1. Artist Hibernate domain object
Listing 11.2. ArtistDb.scala database access with Hibernate
Listing 11.3. Completed ArtistsController.scala
Listing 11.4. artists.jsp to render all the artists
Listing 11.5. Configuring the model and Hibernate using Spring
Listing 11.6. Configuring the controller and web using Spring
Chapter 12. Scalable and distributed applications using Akka
Listing 12.1. WordCountWorker Akka actor in Java
Listing 12.2. MainActor running on a main actor system
Listing 12.3. Complete dataflow concurrency example
Listing 12.4. H2 start and stop actions
Listing 12.5. Akkaoogle build.scala file
Listing 12.6. Akkaoogle schema
Listing 12.7. Complete models package of Akkaoogle
Listing 12.8. List of message types supported by Akkaoogle (messages.scala)
Listing 12.9. Actor that calculates lowest price for internal products
Listing 12.10. The external vendor proxy actor
Listing 12.11. External vendor lowest price calculator
Listing 12.12. Cheapest deal finder actor
Listing 12.13. Akkaoogle actor server
Listing 12.14. Complete monitor actor