##TUTORIAL
###Day 1
###Day 2
####Full day
##TUTORIAL
###Day 1
###Day 2
####Full day
#Code is Data, So Own Your Code!
Other day a co-worker showed me this piece of code and asked me how we could re-write it in a more Scala way.
//generate id based on rule characteristics
if(priceStatusRule && hierarchyRule && markdownRule && lastReceivedDateRule){
priorityId = 1
} else if(hierarchyRule && markdownRule && lastReceivedDateRule && !priceStatusRule){
priorityId = 2
#Questions for Martin Odersky @ Saks ##Grouped by areas
Future of JVM and Scala
Functional Programming
#Coding Exercise ##Abstract
The exercise is broken in 3 parts, as described below. When you are done, follow these steps to delivery your answers.
##Exercises
#How to handle caching in a functional way | |
scala> case class StlCache(pcode : String, stl_pcode : List[String], ttl : Int) | |
defined class StlCache | |
scala> val lamer = StlCache("01", List("02", "03"), 100) | |
lamer: StlCache = StlCache(01,List(02, 03),100) | |
scala> val lancome = StlCache("04", List("05", "06"), 500) | |
lancome: StlCache = StlCache(04,List(05, 06),500) |
package controllers | |
import play.api.mvc._ | |
import ProductDetailService.app.models.{ProductLike, Product} | |
import play.api.libs.json.{Json, JsValue} | |
import scala.concurrent.{Await, Future} | |
import com.s5a.service.utils.Slf4JLogger | |
import com.s5a.service.metrics.Timer | |
import com.s5a.metrics.{MetricNamespace, Recorder} | |
import scala.concurrent.duration._ |
#Java/Scala | |
*.class | |
*.log | |
*.jar | |
# sbt specific | |
dist/* | |
target/ | |
lib_managed/ | |
src_managed/ |
package com.s5a.service.product_repo | |
import com.s5a.service.core.akka.EndpointUriSet | |
import akka.camel.CamelMessage | |
import com.s5a.service.core.akka.SimpleProducer | |
import play.api.libs.json._ | |
import play.api.libs.json.Json._ | |
import play.api.libs.json.JsArray | |
import play.api.libs.json.JsSuccess | |
import play.api.libs.json.JsString |
package com.s5a.cmp.scala.esb | |
import com.s5a.service.core.akka.LifeCycle | |
import com.s5a.config.{Config, S5AConfigFactory} | |
import akka.actor.{ActorRef, ActorSystem} | |
import org.hornetq.jms.server.embedded.EmbeddedJMS | |
import javax.jms.ConnectionFactory | |
import org.apache.camel.component.jms.JmsComponent | |
import org.slf4j.{LoggerFactory, Logger} | |
import akka.camel.CamelExtension |
package com.s5a.service.messages | |
import play.api.libs.json._ | |
import org.slf4j.{LoggerFactory, Logger} | |
import com.eaio.uuid.UUID | |
import org.joda.time.Instant | |
import play.api.libs.json.JsSuccess | |
//{"query" : "inventory", "product_code":"04827348293"} | |
trait Query{ |