• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Rafael Bagmanov «Scala in a wild enterprise»
 

Rafael Bagmanov «Scala in a wild enterprise»

on

  • 1,597 views

 

Statistics

Views

Total Views
1,597
Views on SlideShare
1,590
Embed Views
7

Actions

Likes
3
Downloads
19
Comments
1

2 Embeds 7

http://habrahabr.ru 6
http://widjer.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • A very interesting presentation! I was at the ScalaDev, it's awful that it was too brief due to lack of time.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Rafael Bagmanov «Scala in a wild enterprise» Rafael Bagmanov «Scala in a wild enterprise» Presentation Transcript

    • Scala in a wildenterpriseRafael Bagmanov( Grid Dynamics )the?
    • In what use cases (types of applications)does Scala make the least sense?
    • "Database front end, CRUD apps.Most of the boring apps that are built withStruts and Spring"David Pollak"Barriers to scala adoption" Infoq.com
    • OpenGenesisgithub.com/griddynamics/OpenGenesis
    • ● open source - open-genesis.org● 2 years of development● > 50 KLOC of scala code● successfully deployed to production in onelarge american financial institution● Buzzwords: continuous deployment, cloud,chef, devops, aws, openstackOpenGenesisDeployment orchestration tool
    • ● Integration with legacy apps and data (lots ofSOAP and xml)● sophisticated security policies● IT department separated from developmentteam● J2EE Containers everywhere● Risk averseEnterprise characteristics
    • Typical "lightweight" j2ee stackWeb layerService layerData access layerDBSpring MVCSpringJPA
    • j2ee stack. Scala editionWeb layerService layerData access layerDBSpring MVC + scala magicSpring + scala implicitsJPA Squeryl
    • j2ee stack. Scala editionWeb layerService layerData access layerDBSpring MVCSpringSquerylWAR
    • j2ee stack. Scala edition + scalagoodnessWeb layerService layerData access layerDBSpring MVCSpringSquerylWorkflow distributedengineAkkaWAR
    • Service layer: Spring
    • ● DI fits almost nicely with scalaSpring with scala
    • ● DI fits almost nicely with scalaclass GenesisRestController {@Autowired var genesisService: GenesisService = _}class GenesisRestController {@BeanProperty var genesisService: GenesisService = _}class GenesisRestController (genesisService: GenesisService) {}Spring with scala
    • ● DI fits almost nicely with scala○ "Everything is a trait" approach cant be doneSpring with scala
    • ● DI fits almost nicely with scala○ "Everything is a trait" approach cant be done○ Be aware of type inference in @Configuration beantrait Serviceclass ServiceImpl extends Service@Configurationclass ServiceContext {@Bean def service = new ServiceImpl}Spring with scala
    • ● DI fits almost nicely with scala○ "Everything is a trait" approach cant be done○ Be aware of type inference in @Configuration beantrait Serviceclass ServiceImpl extends Service@Configurationclass ServiceContext {@Bean def service: Service = new ServiceImpl}Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.springLdapTemplate.authenticate("user", "*", "password", newAuthenticationErrorCallback {def execute(e: Exception) {log.error(e)}})Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.springLdapTemplate.authenticate("user", "*", "password", newAuthenticationErrorCallback {def execute(e: Exception) {log.error(e)}})Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.springLdapTemplate.authenticate("user", "*", "password", newAuthenticationErrorCallback {def execute(e: Exception) {log.error(e)}})springLdapTemplate.authenticate("user", "*", "password", log.error(_))Spring with scala
    • ● 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
    • ● DI fits almost nicely with scala● Rich spring templates libraries.● AOP for free (almost)Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.● AOP for free (almost)○ Be aware of naming in debug infodef findUsers(projectId: Int) {dao.findUsers(projectId)}def findUsers2(projectId: Int) {dao.allUsers().filter(_.projectId == projectId)}Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.● AOP for free (almost)○ Be aware of naming in debug infodef findUsers(projectId: Int) { // debugIfo: name "projectId"dao.findUsers(projectId)}def findUsers2(projectId: Int) { // debugInfo: name "projectId$"dao.allUsers().filter(_.projectId == projectId)}Spring with scala
    • ● DI fits almost nicely with scala● Rich spring templates libraries.● AOP for free (almost)● Spring security just worksSpring with scala
    • Persistence layer: Squeryl
    • ● Lightweight ORM written in scalaSqueryl
    • ● Lightweight ORM written in scalaSquerylclass Workflow(override val id: Int) extends KeyedEntity[Int]
    • ● Lightweight ORM written in scalaSquerylclass Workflow(override val id: Int) extends KeyedEntity[Int]object GS extends Schema {val workflows = table[Workflow]}
    • ● Lightweight ORM written in scalaSquerylclass 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))
    • ● Lightweight ORM written in scala○ First class support for scala collections, options, etcSqueryl
    • ● Lightweight ORM written in scala○ First class support for scala collections, options, etc○ Integrates with spring transaction management(not out of the box)Squeryl
    • ● 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))
    • Squeryl● Lightweight ORM written in scala○ Likes heap in the same proportion asHibernate doeshibernate squeryl
    • ● Lightweight ORM written in scala○ Likes heap in the same proportion asHibernate does○ Lots of "black magic" in source codeSqueryl
    • ● Lightweight ORM written in scala● Internal scala DSL for writing queries○ Type safe queries - compile time syntax checkSqueryl
    • ● Lightweight ORM written in scala● Internal scala DSL for writing queries○ Lots of "black magic" in source codeSqueryl
    • ● Lightweight ORM written in scala● Internal scala DSL for writing queries○ Lots of "black magic" in source code○ Fallback on native sql is not easySqueryl
    • ● Lightweight ORM written in scala● Internal scala DSL for writing queries○ Lots of "black magic" in source code○ Fallback on native sql is not easy○ Lots of implicits drives IDE crazy andincreases compilation timeSqueryl
    • ● Lightweight ORM written in scala● Internal scala DSL for writing queries○ Lots of "black magic" in source code○ Fallback on native sql is not easy○ Lots of implicits drives IDE crazy andincrease compilation time○ The approach is somewhat flawed (opinion)Squeryl
    • Web layer: Spring MVClift-jsonscala magic
    • ● RESTfull web servicesWeb layercase class User (@NotBlank username: String,@Email @Size(min = 1, max = 256) email: String,password: Option[String])@Controller@RequestMapping(Array("/rest/users"))class UsersController {@RequestMapping(method = Array(RequestMethod.POST))@ResponseBodydef create(@RequestBody @Valid request: User): User = userService.create(request)}
    • ● RESTfull web services● Easy to make Hypermedia REST withimplicitsWeb layer@Controller@RequestMapping(Array("/rest/users"))class UsersController {import com.griddynamics.genesis.rest.links.Hypermedia._@RequestMapping(method = Array(RequestMethod.POST))@ResponseBodydef create(@RequestBody @Valid request: User): Hypermedia[User] = {userService.create(request).withLink("/rest/users", LinkType.SELF)}
    • Couple of words aboutAKKA
    • Ехал Акка через АккаСмотрит Акка в Акка АккаСунул Акка Акка в АккаАкка Акка Акка Акка ** Ode to Akka in russian
    • Greatest challenge:
    • Greatest challenge:People
    • ● Hiring is hardChallenges
    • ● Hiring is hard○ Scala is a talent attractionChallenges
    • ● Hiring is hard○ Scala is a talent attraction○ In avg: 0.5 interview per monthChallenges
    • ● Hiring is hard● Settling team standards and codeconventionChallenges
    • ● Hiring is hard● Settling team standards and codeconvention○ Tools are not there yetChallenges
    • ● Hiring is hard● Settling team standards and codeconvention○ Tools are not there yet○ Between "OCaml" and "Java" firesChallenges
    • ● Hiring is hard● Settling team standards and codeconvention○ Tools are not there yet○ Between "OCaml" and "Java" fires○ "Effective scala" by Twitter and "Scala style guide"might help (a bit)Challenges
    • The greatest code-review mystery ofall timesif (option.isDefined) {..}option.foreach { .. }option match {case Some(x) => ..case None => ..}How to deal with scala.Option?
    • The greatest code-review mystery ofall timesif (option.isDefined) {..}option.foreach { .. }option match {case Some(x) => ..case None => ..}How to deal with scala.Option?
    • Recruiting javadevelopers
    • aka
    • 5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief
    • 1. Denial2. Anger3. Bargaining4. Depression5. Acceptance5 stages of grief