8. ● open source - open-genesis.org
● 2 years of development
● > 50 KLOC of scala code
● successfully deployed to production in one
large american financial institution
● Buzzwords: continuous deployment, cloud,
chef, devops, aws, openstack
OpenGenesis
Deployment orchestration tool
9. ● Integration with legacy apps and data (lots of
SOAP and xml)
● sophisticated security policies
● IT department separated from development
team
● J2EE Containers everywhere
● Risk averse
Enterprise characteristics
11. j2ee stack. Scala edition
Web layer
Service layer
Data access layer
DB
Spring MVC + scala magic
Spring + scala implicits
JPA Squeryl
12. j2ee stack. Scala edition
Web layer
Service layer
Data access layer
DB
Spring MVC
Spring
Squeryl
WAR
13. j2ee stack. Scala edition + scala
goodness
Web layer
Service layer
Data access layer
DB
Spring MVC
Spring
Squeryl
Workflow distributed
engine
Akka
WAR
15. ● DI fits almost nicely with scala
Spring with scala
16. ● DI fits almost nicely with scala
class GenesisRestController {
@Autowired var genesisService: GenesisService = _
}
class GenesisRestController {
@BeanProperty var genesisService: GenesisService = _
}
class GenesisRestController (genesisService: GenesisService) {}
Spring with scala
17. ● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
Spring with scala
18. ● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
○ Be aware of type inference in @Configuration bean
trait Service
class ServiceImpl extends Service
@Configuration
class ServiceContext {
@Bean def service = new ServiceImpl
}
Spring with scala
19. ● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
○ Be aware of type inference in @Configuration bean
trait Service
class ServiceImpl extends Service
@Configuration
class ServiceContext {
@Bean def service: Service = new ServiceImpl
}
Spring with scala
20. ● DI fits almost nicely with scala
● Rich spring templates libraries.
Spring with scala
21. ● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
Spring with scala
22. ● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
Spring with scala
23. ● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
springLdapTemplate.authenticate("user", "*", "password", log.error(_))
Spring with scala
24. ● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", log.error(_))
implicit def authErrorCallbackWrapper(func:(Exception) => Any) = {
new AuthenticationErrorCallback {
def execute(exception: Exception): Unit = func(exception)
}
}
Spring with scala
25. ● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
Spring with scala
26. ● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
○ Be aware of naming in debug info
def findUsers(projectId: Int) {
dao.findUsers(projectId)
}
def findUsers2(projectId: Int) {
dao.allUsers().filter(_.projectId == projectId)
}
Spring with scala
27. ● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
○ Be aware of naming in debug info
def findUsers(projectId: Int) { // debugIfo: name "projectId"
dao.findUsers(projectId)
}
def findUsers2(projectId: Int) { // debugInfo: name "projectId$"
dao.allUsers().filter(_.projectId == projectId)
}
Spring with scala
28. ● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
● Spring security just works
Spring with scala
31. ● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
32. ● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
object GS extends Schema {
val workflows = table[Workflow]
}
33. ● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
object GS extends Schema {
val workflows = table[Workflow]
}
def find(workflowId: Int) = from(GS.workflows)(w =>
where(w.id === workflowId)
select (w)
orderBy(w.id desc)
)
34. ● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
Squeryl
35. ● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
○ Integrates with spring transaction management
(not out of the box)
Squeryl
36. ● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
○ Integrates with spring transaction management
(not out of the box)
Squeryl
@Transactional(propagation = REQUIRES_NEW)
def find(workflowId: Int) = from(GS.workflows)(w =>
where(w.id === workflowId)
select (w)
orderBy(w.id desc)
)
37. Squeryl
● Lightweight ORM written in scala
○ Likes heap in the same proportion as
Hibernate does
hibernate squeryl
38. ● Lightweight ORM written in scala
○ Likes heap in the same proportion as
Hibernate does
○ Lot's of "black magic" in source code
Squeryl
39. ● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Type safe queries - compile time syntax check
Squeryl
40. ● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
Squeryl
41. ● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
Squeryl
42. ● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
○ Lots of implicits drives IDE crazy and
increases compilation time
Squeryl
43. ● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
○ Lots of implicits drives IDE crazy and
increase compilation time
○ The approach is somewhat flawed (opinion)
Squeryl
52. ● Hiring is hard
○ Scala is a talent attraction
Challenges
53. ● Hiring is hard
○ Scala is a talent attraction
○ In avg: 0.5 interview per month
Challenges
54. ● Hiring is hard
● Settling team standards and code
convention
Challenges
55. ● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
Challenges
56. ● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
○ Between "OCaml" and "Java" fires
Challenges
57. ● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
○ Between "OCaml" and "Java" fires
○ "Effective scala" by Twitter and "Scala style guide"
might help (a bit)
Challenges
58. The greatest code-review mystery of
all times
if (option.isDefined) {
..
}
option.foreach { .. }
option match {
case Some(x) => ..
case None => ..
}
How to deal with scala.Option
?
59. The greatest code-review mystery of
all times
if (option.isDefined) {
..
}
option.foreach { .. }
option match {
case Some(x) => ..
case None => ..
}
How to deal with scala.Option
?