SlideShare a Scribd company logo
1 of 20
Expressing The Context
A functional way
Rodrigo Gómez de Agüero
SUGAR - Scala MeetUp
Agosto 2017
Two Scala features
● Implicit Conversion & Implicit Parameters
● Self-type annotation
The Context is...
“The parts of something written or spoken that
immediately precede and follow a word or
passage and clarify its meaning.”
What surrounds us
● The current configuration
● The current user
● Environment (Dev, QA, Prod, etc)
● Security Level
● Etc.
Expressing the Context
● Global variables
● Monkey Patch
● Dependency Injection
● Cake Pattern
The Functional Way
“Parametrize all”
● No Side-effect
● Type-Safe
● Grained Control
But too many parameters
is tedious
Leave some of them implicit.
Implicits
● Improve the semantics on APIs
● It allows to create designs more robust and
elegant.
Implicit Parameters
● When an implicit parameter don’t have an
argument, then the compiler tries to find a
value for that parameter.
● If more than one exists, chooses the more
specific one.
● If candidates are not uniques, an ambiguity
error is thrown.
Implicit Conversion
● If exists an expression where the Types are
not assignable, the compiler tries to find an
implicit method that make the conversion.
● The search rule is the same as for implicit
parameters.
Use Case: DSL
Use Case: Type Conversion
Use Case: Passing Context
Self-Type Annotation
● Declare dependencies between Types
● A self-type is a way to narrow the type of this
or another identifier that aliases this.
Self-Type Annotation
The Cake Pattern
● A way to modularize components and Inject
Dependencies supported by the language.
● Read the Martin Ordersky paper: Scalable
Components Abstraction
● Is a boilerplate pattern but there are some
variation that minimize the code.
The Cake Pattern
The Cake Pattern
The Cake Pattern with Implicit
Thanks!

More Related Content

What's hot

Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming Paradigm
Tech Triveni
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code Review
Richard Huang
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 

What's hot (20)

Core conv
Core convCore conv
Core conv
 
Building APIs using Laravel - A simple approach to scale
Building APIs using Laravel - A simple approach to scaleBuilding APIs using Laravel - A simple approach to scale
Building APIs using Laravel - A simple approach to scale
 
Advanced Search using JQL in JIRA
Advanced Search using JQL in JIRAAdvanced Search using JQL in JIRA
Advanced Search using JQL in JIRA
 
Deployment in Drupal 8
Deployment in Drupal 8Deployment in Drupal 8
Deployment in Drupal 8
 
Charlie Talk - JQL In A Nutshell
Charlie Talk - JQL In A NutshellCharlie Talk - JQL In A Nutshell
Charlie Talk - JQL In A Nutshell
 
Design & Prototype an API
Design & Prototype an APIDesign & Prototype an API
Design & Prototype an API
 
Android clean architecture workshop 3h edition
Android clean architecture workshop 3h editionAndroid clean architecture workshop 3h edition
Android clean architecture workshop 3h edition
 
Hundreds of Microservices without Breaking Your APIs
Hundreds of Microservices without Breaking Your APIsHundreds of Microservices without Breaking Your APIs
Hundreds of Microservices without Breaking Your APIs
 
The Big Wave of Indian Startups - Almost Effortless Entrepreneurship Using Ruby
The Big Wave of Indian Startups - Almost Effortless Entrepreneurship Using RubyThe Big Wave of Indian Startups - Almost Effortless Entrepreneurship Using Ruby
The Big Wave of Indian Startups - Almost Effortless Entrepreneurship Using Ruby
 
Functional Reactive Programming
Functional Reactive ProgrammingFunctional Reactive Programming
Functional Reactive Programming
 
Message Queues in Ruby - An Overview
Message Queues in Ruby - An OverviewMessage Queues in Ruby - An Overview
Message Queues in Ruby - An Overview
 
Clean architecture workshop
Clean architecture workshopClean architecture workshop
Clean architecture workshop
 
Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming Paradigm
 
Specs2 3.0
Specs2 3.0Specs2 3.0
Specs2 3.0
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code Review
 
The Art of Giving and Receiving Code Reviews
The Art of Giving and Receiving Code ReviewsThe Art of Giving and Receiving Code Reviews
The Art of Giving and Receiving Code Reviews
 
The Rounds Project: Growing from thousands to millions - Berry Ventura & Yoah...
The Rounds Project: Growing from thousands to millions - Berry Ventura & Yoah...The Rounds Project: Growing from thousands to millions - Berry Ventura & Yoah...
The Rounds Project: Growing from thousands to millions - Berry Ventura & Yoah...
 
Advantages of Rails Framework
Advantages of Rails FrameworkAdvantages of Rails Framework
Advantages of Rails Framework
 
Specs2 3.4
Specs2 3.4Specs2 3.4
Specs2 3.4
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 

Similar to Expressing the Context - A Functional Way

RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
dcieslak
 

Similar to Expressing the Context - A Functional Way (20)

Lessons Learned When Automating
Lessons Learned When AutomatingLessons Learned When Automating
Lessons Learned When Automating
 
Don't Suck at Building Stuff - Mykel Alvis at Puppet Camp Altanta
Don't Suck at Building Stuff  - Mykel Alvis at Puppet Camp AltantaDon't Suck at Building Stuff  - Mykel Alvis at Puppet Camp Altanta
Don't Suck at Building Stuff - Mykel Alvis at Puppet Camp Altanta
 
A Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache SparkA Tool For Big Data Analysis using Apache Spark
A Tool For Big Data Analysis using Apache Spark
 
Deccan ruby-conf-talk
Deccan ruby-conf-talkDeccan ruby-conf-talk
Deccan ruby-conf-talk
 
Stop Sucking at Building Stuff!
Stop Sucking at Building Stuff!Stop Sucking at Building Stuff!
Stop Sucking at Building Stuff!
 
Evaluating a password manager
Evaluating a password managerEvaluating a password manager
Evaluating a password manager
 
How to add Fixtures into your Django app with Mixer
How to add Fixtures into your Django app with MixerHow to add Fixtures into your Django app with Mixer
How to add Fixtures into your Django app with Mixer
 
London SDET Meetup main presentation - How SDET can transform your organisati...
London SDET Meetup main presentation - How SDET can transform your organisati...London SDET Meetup main presentation - How SDET can transform your organisati...
London SDET Meetup main presentation - How SDET can transform your organisati...
 
Django
DjangoDjango
Django
 
ATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD Approach
 
Selenium done right
Selenium done rightSelenium done right
Selenium done right
 
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
Testistanbul 2016 - Keynote: "Why Automated Verification Matters" by Kristian...
 
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
RandomTest - Random Software Integration Tests That Just Work for C/C++, Java...
 
Laravel ile Hızlı ve Modern Web Programlama, Ömer Çıtak
Laravel ile Hızlı ve Modern Web Programlama, Ömer ÇıtakLaravel ile Hızlı ve Modern Web Programlama, Ömer Çıtak
Laravel ile Hızlı ve Modern Web Programlama, Ömer Çıtak
 
Laravel ile hızlı ve modern web programlama
Laravel ile hızlı ve modern web programlamaLaravel ile hızlı ve modern web programlama
Laravel ile hızlı ve modern web programlama
 
Testing with Express, Mocha & Chai
Testing with Express, Mocha & ChaiTesting with Express, Mocha & Chai
Testing with Express, Mocha & Chai
 
Implementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor DeryaginImplementing GraphQL API in Elixir – Victor Deryagin
Implementing GraphQL API in Elixir – Victor Deryagin
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
 
Path Dependent Development (PyCon AU)
Path Dependent Development (PyCon AU)Path Dependent Development (PyCon AU)
Path Dependent Development (PyCon AU)
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Expressing the Context - A Functional Way

Editor's Notes

  1. Prueba