SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Scala collections
architecture:
DRY done well
Ofer Ron| October 2013
Huh?
Our goal is understanding:
def map[B, That](f: A => B)
(implicit bf: CanBuildFrom[Repr, B, That]): That
The collection traits
Traversable – the wanted behavior
trait Traversable[+A] {
def foreach[U](f:A=>U)
def filter(p:A=>Boolean):???
}
What’s the right return type?
The challenge
The reasonable behavior
List[A] List[A]
filter(f:A=>Boolean)
Bonus question:
Set[A] Set[A]
filter(f:A=>Boolean)
String String
filter(f:Char=>Boolean)
Building every type
class Builder[-Elem,+To] {
def +=(elem: Elem): this.type = . . .
def result(): To = . . .
def clear() = . . .
}
TraversableLike – abstractions
trait TraversableLike[+Elem,+Repr] {
def newBuilder:Builder[Elem,Repr]
def foreach[U](f:Elem=>U)
def filter(p:Elem=>Boolean):Repr = {
val b = newBuilder
foreach (e => if (p(e)) b+= e)
b.result
}
}
TraversableLike – abstractions
trait Traversable[+Elem] extends
TraversableLike[Elem,Traversable[Elem]] {…}
Abstract on implementation and type
We can filter, now what?
The reasonable behavior for map
List[A] List[B]
map(f:A=>B)
Set[A] Set[B]
map(f:A=>B)
Can the old solution work?
BitSet
BitSet
Set[String]
Can the old solution work? – another example
Map[A,B]
Map[C,D]
Iterable[C]
Aside - Functional dependencies
trait Matrix, trait Vector
Matrix * Vector => Vector
Matrix * Matrix => Matrix
Int * Matrix => Matrix
Vector * Vector => undefined
Aside - Functional dependencies – cnt’d
trait Mult [A,B,C] {
def apply(a:A,b:B):C
}
def multiply[A,B,C](a:A,b:B)(implicit mult:Mult[A,B,C]) =
mult(a,b)
implicit object MatrixVectorMult extends
Mult[Matrix,Vector,Vector]
CanBuildFrom - Using Functional dependencies
trait TraversableLike[+A,+Repr] {
def map[B, That](f: A => B)
(implicit bf: CanBuildFrom[Repr, B, That]): That = ???
}
trait CanBuildFrom[-Collection, -NewElem, +Result] {
def apply(from: Collection): Builder[NewElem, Result]
}
The BitSet hierarchy
TraversableLike[+A,+Repr]
SetLike[A,+Repr]
BitSetLike[+This <: BitSetLike[This]
with Set[Int]]
Traversable[+A]
Set[A]
BitSet
A=Int
A=Int
CanBuildFrom - Using Functional dependencies
object Set {
implicit def canBuildFromSet[B] = new
CanBuildFrom[Set[_], B, Set[B]] {…}
}
object BitSet {
implicit def canBuildFromBitSet[B] = new
CanBuildFrom[BitSet, Int, BitSet] {…}
}
Static vs dynamic type
val els:Iterable[Int] = List(1,2,3)
Static type Dynamic type
def map[A,B](els:Iterable[A])(f:A=>B):Iterable[B] = els map f
val newEls:Iterable[String] = map(List(1,2,3))(_.toString)
We want dynamic type list
Static vs dynamic type – cnt’d
Compiler will capture: CanBuildFrom[Iterable[_],B,Iterable[B]]
We can follow the call chain to understand how the
correct dynamic type can be created
Static vs dynamic type – cnt’d
New Coursera course:
Principles of Reactive Programming
Martin Odersky, Erik Meijer and Roland Kuhn
Nov. 4th, 2013
Thank You
We’re hiring!

Weitere ähnliche Inhalte

Andere mochten auch

How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortalsDave Haeffner
 
Full Stack Testing Done Well
Full Stack Testing Done WellFull Stack Testing Done Well
Full Stack Testing Done WellDave Haeffner
 
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with  selenide, nselene, selene & capybaraWeb ui tests examples with  selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybaraIakiv Kramarenko
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - ENIakiv Kramarenko
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToGlobalLogic Ukraine
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Iakiv Kramarenko
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 minIakiv Kramarenko
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users AnonymousDave Haeffner
 
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Iakiv Kramarenko
 
Cucumber Crash Course
Cucumber Crash CourseCucumber Crash Course
Cucumber Crash CourseDave Haeffner
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and EasybIakiv Kramarenko
 

Andere mochten auch (17)

How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortals
 
Full Stack Testing Done Well
Full Stack Testing Done WellFull Stack Testing Done Well
Full Stack Testing Done Well
 
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with  selenide, nselene, selene & capybaraWeb ui tests examples with  selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybara
 
Selenium Basics
Selenium BasicsSelenium Basics
Selenium Basics
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How To
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 min
 
Bdd lessons-learned
Bdd lessons-learnedBdd lessons-learned
Bdd lessons-learned
 
Easy automation.py
Easy automation.pyEasy automation.py
Easy automation.py
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users Anonymous
 
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
 
Cucumber Crash Course
Cucumber Crash CourseCucumber Crash Course
Cucumber Crash Course
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
 

Mehr von LivePerson

Microservices on top of kafka
Microservices on top of kafkaMicroservices on top of kafka
Microservices on top of kafkaLivePerson
 
Graph QL Introduction
Graph QL IntroductionGraph QL Introduction
Graph QL IntroductionLivePerson
 
Measure() or die()
Measure() or die() Measure() or die()
Measure() or die() LivePerson
 
Resilience from Theory to Practice
Resilience from Theory to PracticeResilience from Theory to Practice
Resilience from Theory to PracticeLivePerson
 
System Revolution- How We Did It
System Revolution- How We Did It System Revolution- How We Did It
System Revolution- How We Did It LivePerson
 
Liveperson DLD 2015
Liveperson DLD 2015 Liveperson DLD 2015
Liveperson DLD 2015 LivePerson
 
Http 2: Should I care?
Http 2: Should I care?Http 2: Should I care?
Http 2: Should I care?LivePerson
 
Mobile app real-time content modifications using websockets
Mobile app real-time content modifications using websocketsMobile app real-time content modifications using websockets
Mobile app real-time content modifications using websocketsLivePerson
 
Mobile SDK: Considerations & Best Practices
Mobile SDK: Considerations & Best Practices Mobile SDK: Considerations & Best Practices
Mobile SDK: Considerations & Best Practices LivePerson
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]LivePerson
 
Apache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonApache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonLivePerson
 
Data compression in Modern Application
Data compression in Modern ApplicationData compression in Modern Application
Data compression in Modern ApplicationLivePerson
 
Support Office Hour Webinar - LivePerson API
Support Office Hour Webinar - LivePerson API Support Office Hour Webinar - LivePerson API
Support Office Hour Webinar - LivePerson API LivePerson
 
SIP - Introduction to SIP Protocol
SIP - Introduction to SIP ProtocolSIP - Introduction to SIP Protocol
SIP - Introduction to SIP ProtocolLivePerson
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceLivePerson
 
Building Enterprise Level End-To-End Monitor System with Open Source Solution...
Building Enterprise Level End-To-End Monitor System with Open Source Solution...Building Enterprise Level End-To-End Monitor System with Open Source Solution...
Building Enterprise Level End-To-End Monitor System with Open Source Solution...LivePerson
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceLivePerson
 
From a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonFrom a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonLivePerson
 
How can A/B testing go wrong?
How can A/B testing go wrong?How can A/B testing go wrong?
How can A/B testing go wrong?LivePerson
 

Mehr von LivePerson (20)

Microservices on top of kafka
Microservices on top of kafkaMicroservices on top of kafka
Microservices on top of kafka
 
Graph QL Introduction
Graph QL IntroductionGraph QL Introduction
Graph QL Introduction
 
Measure() or die()
Measure() or die() Measure() or die()
Measure() or die()
 
Resilience from Theory to Practice
Resilience from Theory to PracticeResilience from Theory to Practice
Resilience from Theory to Practice
 
System Revolution- How We Did It
System Revolution- How We Did It System Revolution- How We Did It
System Revolution- How We Did It
 
Liveperson DLD 2015
Liveperson DLD 2015 Liveperson DLD 2015
Liveperson DLD 2015
 
Http 2: Should I care?
Http 2: Should I care?Http 2: Should I care?
Http 2: Should I care?
 
Mobile app real-time content modifications using websockets
Mobile app real-time content modifications using websocketsMobile app real-time content modifications using websockets
Mobile app real-time content modifications using websockets
 
Mobile SDK: Considerations & Best Practices
Mobile SDK: Considerations & Best Practices Mobile SDK: Considerations & Best Practices
Mobile SDK: Considerations & Best Practices
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]
 
Apache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePersonApache Avro and Messaging at Scale in LivePerson
Apache Avro and Messaging at Scale in LivePerson
 
Data compression in Modern Application
Data compression in Modern ApplicationData compression in Modern Application
Data compression in Modern Application
 
Support Office Hour Webinar - LivePerson API
Support Office Hour Webinar - LivePerson API Support Office Hour Webinar - LivePerson API
Support Office Hour Webinar - LivePerson API
 
SIP - Introduction to SIP Protocol
SIP - Introduction to SIP ProtocolSIP - Introduction to SIP Protocol
SIP - Introduction to SIP Protocol
 
Scalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduceScalding: Reaching Efficient MapReduce
Scalding: Reaching Efficient MapReduce
 
Building Enterprise Level End-To-End Monitor System with Open Source Solution...
Building Enterprise Level End-To-End Monitor System with Open Source Solution...Building Enterprise Level End-To-End Monitor System with Open Source Solution...
Building Enterprise Level End-To-End Monitor System with Open Source Solution...
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
From a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePersonFrom a Kafkaesque Story to The Promised Land at LivePerson
From a Kafkaesque Story to The Promised Land at LivePerson
 
How can A/B testing go wrong?
How can A/B testing go wrong?How can A/B testing go wrong?
How can A/B testing go wrong?
 

Kürzlich hochgeladen

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Kürzlich hochgeladen (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Scala Collections Architecture: DRY Done Well

  • 1. Scala collections architecture: DRY done well Ofer Ron| October 2013
  • 2. Huh? Our goal is understanding: def map[B, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That
  • 4. Traversable – the wanted behavior trait Traversable[+A] { def foreach[U](f:A=>U) def filter(p:A=>Boolean):??? } What’s the right return type?
  • 5. The challenge The reasonable behavior List[A] List[A] filter(f:A=>Boolean) Bonus question: Set[A] Set[A] filter(f:A=>Boolean) String String filter(f:Char=>Boolean)
  • 6. Building every type class Builder[-Elem,+To] { def +=(elem: Elem): this.type = . . . def result(): To = . . . def clear() = . . . }
  • 7. TraversableLike – abstractions trait TraversableLike[+Elem,+Repr] { def newBuilder:Builder[Elem,Repr] def foreach[U](f:Elem=>U) def filter(p:Elem=>Boolean):Repr = { val b = newBuilder foreach (e => if (p(e)) b+= e) b.result } }
  • 8. TraversableLike – abstractions trait Traversable[+Elem] extends TraversableLike[Elem,Traversable[Elem]] {…} Abstract on implementation and type
  • 9. We can filter, now what? The reasonable behavior for map List[A] List[B] map(f:A=>B) Set[A] Set[B] map(f:A=>B)
  • 10. Can the old solution work? BitSet BitSet Set[String]
  • 11. Can the old solution work? – another example Map[A,B] Map[C,D] Iterable[C]
  • 12. Aside - Functional dependencies trait Matrix, trait Vector Matrix * Vector => Vector Matrix * Matrix => Matrix Int * Matrix => Matrix Vector * Vector => undefined
  • 13. Aside - Functional dependencies – cnt’d trait Mult [A,B,C] { def apply(a:A,b:B):C } def multiply[A,B,C](a:A,b:B)(implicit mult:Mult[A,B,C]) = mult(a,b) implicit object MatrixVectorMult extends Mult[Matrix,Vector,Vector]
  • 14. CanBuildFrom - Using Functional dependencies trait TraversableLike[+A,+Repr] { def map[B, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = ??? } trait CanBuildFrom[-Collection, -NewElem, +Result] { def apply(from: Collection): Builder[NewElem, Result] }
  • 15. The BitSet hierarchy TraversableLike[+A,+Repr] SetLike[A,+Repr] BitSetLike[+This <: BitSetLike[This] with Set[Int]] Traversable[+A] Set[A] BitSet A=Int A=Int
  • 16. CanBuildFrom - Using Functional dependencies object Set { implicit def canBuildFromSet[B] = new CanBuildFrom[Set[_], B, Set[B]] {…} } object BitSet { implicit def canBuildFromBitSet[B] = new CanBuildFrom[BitSet, Int, BitSet] {…} }
  • 17. Static vs dynamic type val els:Iterable[Int] = List(1,2,3) Static type Dynamic type def map[A,B](els:Iterable[A])(f:A=>B):Iterable[B] = els map f val newEls:Iterable[String] = map(List(1,2,3))(_.toString) We want dynamic type list
  • 18. Static vs dynamic type – cnt’d Compiler will capture: CanBuildFrom[Iterable[_],B,Iterable[B]] We can follow the call chain to understand how the correct dynamic type can be created
  • 19. Static vs dynamic type – cnt’d New Coursera course: Principles of Reactive Programming Martin Odersky, Erik Meijer and Roland Kuhn Nov. 4th, 2013

Hinweis der Redaktion

  1. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  2. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  3. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  4. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  5. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  6. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  7. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  8. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  9. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  10. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  11. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  12. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  13. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  14. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  15. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  16. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  17. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether
  18. Global research of 600 consumers’ expectation of help – when purchasing online, 1/3 expect to be helped immediately, whilewhen purchasing online, ¾ expect to be able to access help within 5 minutesif a response is not delivered in the expected timeframe 50% will shop elsewhere online, or abandon altogether