Phantom types allow using the type system to enforce correctness by distinguishing types that are never instantiated at runtime. The summary describes how phantom types can be used to define a Form trait where the type parameter distinguishes validated and unvalidated form data, ensuring validation is performed before accessing validated data. This provides static type safety without runtime overhead from phantom types, which are never instantiated.
A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
I love Scala, I really do. I find Scala both more productive and more fun then any of the many languages I have worked with before. There are many reasons to use to Scala; however, I will not be talking about them.
Instead, in this talk I will cover some of the things I find annoying or disappointing in Scala. For each I will explain the issue, why it is so, whether or not it is likely to ever change, and what, if anything, we can do about it in the mean time.
The issues covered will include:
Limitations on type inference
Type Erasure
Binary incompatibility
Limitations on overloading
Standard library quality
And more
The lecture is geared towards those who have written between 10 and 10 millions lines of Scala code.
A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
I love Scala, I really do. I find Scala both more productive and more fun then any of the many languages I have worked with before. There are many reasons to use to Scala; however, I will not be talking about them.
Instead, in this talk I will cover some of the things I find annoying or disappointing in Scala. For each I will explain the issue, why it is so, whether or not it is likely to ever change, and what, if anything, we can do about it in the mean time.
The issues covered will include:
Limitations on type inference
Type Erasure
Binary incompatibility
Limitations on overloading
Standard library quality
And more
The lecture is geared towards those who have written between 10 and 10 millions lines of Scala code.
An overview of the fundamental features of JavaScript, highlighting the unexpected and obscure features that make it behave different than other languages in the C family.
This is a toy compiler for the course Compiler 2016 at ACM Class, SJTU. The source language is Mx*. The target is MIPS assembly (in SPIM format).
You can refer to my presentation slides to know something about this compiler and also what I've learnt during the course.
Github: https://github.com/abcdabcd987/compiler2016
When debugging this compiler, I wrote another project LLIRInterpreter(https://github.com/abcdabcd987/LLIRInterpreter) which reads text IR and does interpretation.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
Getting started with typescript and angular 2Knoldus Inc.
The Typescript is getting popular day by day, mainly because of its use in angular 2 and its type annotation in these slides i give a brief introduction to typescript and how it works with angular2
“Insulin” for Scala’s Syntactic DiabetesTzach Zohar
See http://www.scalapeno.org.il/#!tzach-zohar/jwhyy:
One of the most common criticisms of Scala, and indeed one of the most concerning ones - is its "Syntactic Diabetes": There's so much "Syntactic Sugar" - so many different ways to code the same thing - that developers might easily get lost. This makes many developers and organizations weary of adopting Scala as a primary language, fearing the training and maintenance costs this problem might entail.
In this talk we'll explain the problem through some real-life examples from Kenshoo's 2- year experience with Scala, and move on to the solutions applied at Kenshoo and elsewhere to resolve this. Among these, we'll discuss style guides, automatic style checkers, Odersky's "Scala Levels", code review tips and more.
If you're a developer thinking about trying Scala out, or a Scala enthusiast trying to convince your teammates or bosses to do so - this talk is for you.
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...Edureka!
( ** Full Stack Web Development Training: https://www.edureka.co/masters-program/full-stack-developer-training ** )
This Edureka tutorial on JavaScript explains all the fundamentals of JavaScript with examples. It also explains various features and applications of JavaScript. Following are the topics included in this tutorial:
1. What Is JavaScript?
2. Why Use JavaScript
3. JavaScript Fundamentals
- Data Types
- Variables
- Constants
- Loops
- Conditional Statements
- Functions
Advanced Scala reflection & runtime meta-programming. The Scala compiler toolbox. Reading Scala Annotations and overcoming type erasure with some real world use cases.
The presentation helps us in understanding the different concepts associated with TypeScript. What is TypeScript? Why is TypeScript used and the different applications of TypeScript. For more information you can simply visit: http://mobile.folio3.com/
As the author of an open-source serialization library in Scala, I've undergone a lot of struggle to understand and harness the power of Scala's type system. My library was based on parsing pickled Scala signatures, which was a subterranean and sparely documented feature of Scala 2.8. I wanted to serialize and deserialize options, lists and maps, which required defeating type erasure when serializing while skating by on type erasure when deserializing. I struggled with multiple constructors, checking for annotation types, specialization, more. The new reflection libraries introduced in Scala 2.10 provided easier access to the same information I had been getting from the pickled signatures. This talk will address practical aspects of type mining, providing a library of hands-on examples using the Scala 2.10 reflection API.
An overview of the fundamental features of JavaScript, highlighting the unexpected and obscure features that make it behave different than other languages in the C family.
This is a toy compiler for the course Compiler 2016 at ACM Class, SJTU. The source language is Mx*. The target is MIPS assembly (in SPIM format).
You can refer to my presentation slides to know something about this compiler and also what I've learnt during the course.
Github: https://github.com/abcdabcd987/compiler2016
When debugging this compiler, I wrote another project LLIRInterpreter(https://github.com/abcdabcd987/LLIRInterpreter) which reads text IR and does interpretation.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
Getting started with typescript and angular 2Knoldus Inc.
The Typescript is getting popular day by day, mainly because of its use in angular 2 and its type annotation in these slides i give a brief introduction to typescript and how it works with angular2
“Insulin” for Scala’s Syntactic DiabetesTzach Zohar
See http://www.scalapeno.org.il/#!tzach-zohar/jwhyy:
One of the most common criticisms of Scala, and indeed one of the most concerning ones - is its "Syntactic Diabetes": There's so much "Syntactic Sugar" - so many different ways to code the same thing - that developers might easily get lost. This makes many developers and organizations weary of adopting Scala as a primary language, fearing the training and maintenance costs this problem might entail.
In this talk we'll explain the problem through some real-life examples from Kenshoo's 2- year experience with Scala, and move on to the solutions applied at Kenshoo and elsewhere to resolve this. Among these, we'll discuss style guides, automatic style checkers, Odersky's "Scala Levels", code review tips and more.
If you're a developer thinking about trying Scala out, or a Scala enthusiast trying to convince your teammates or bosses to do so - this talk is for you.
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...Edureka!
( ** Full Stack Web Development Training: https://www.edureka.co/masters-program/full-stack-developer-training ** )
This Edureka tutorial on JavaScript explains all the fundamentals of JavaScript with examples. It also explains various features and applications of JavaScript. Following are the topics included in this tutorial:
1. What Is JavaScript?
2. Why Use JavaScript
3. JavaScript Fundamentals
- Data Types
- Variables
- Constants
- Loops
- Conditional Statements
- Functions
Advanced Scala reflection & runtime meta-programming. The Scala compiler toolbox. Reading Scala Annotations and overcoming type erasure with some real world use cases.
The presentation helps us in understanding the different concepts associated with TypeScript. What is TypeScript? Why is TypeScript used and the different applications of TypeScript. For more information you can simply visit: http://mobile.folio3.com/
As the author of an open-source serialization library in Scala, I've undergone a lot of struggle to understand and harness the power of Scala's type system. My library was based on parsing pickled Scala signatures, which was a subterranean and sparely documented feature of Scala 2.8. I wanted to serialize and deserialize options, lists and maps, which required defeating type erasure when serializing while skating by on type erasure when deserializing. I struggled with multiple constructors, checking for annotation types, specialization, more. The new reflection libraries introduced in Scala 2.10 provided easier access to the same information I had been getting from the pickled signatures. This talk will address practical aspects of type mining, providing a library of hands-on examples using the Scala 2.10 reflection API.
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
These are the slides from a talk I gave at the Waterloo Scala Meetup on October 9th 2013. The talk was geared toward describing the purpose of implicits, use cases, and getting past that initial hump of "what are they and why would I need them" in order to get people to start exploring the ideas.
Scal`a`ngular a term composed of Scala and Angular JS, a relationship, a handshake between Scala and Angular JS.
It's a way to build AngularJS based applications in a type-safe manner with Scala, Way to provide the bindings to core AngularJS classes and functions.
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Jonas Bonér
Akka is the platform for the next generation event-driven, scalable and fault-tolerant architectures on the JVM
We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it's because we are using the wrong tools and the wrong level of abstraction.
Akka is here to change that.
Using the Actor Model together with Software Transactional Memory we raise the abstraction level and provides a better platform to build correct concurrent and scalable applications.
For fault-tolerance we adopt the "Let it crash" / "Embrace failure" model which have been used with great success in the telecom industry to build applications that self-heals, systems that never stop.
Actors also provides the abstraction for transparent distribution and the basis for truly scalable and fault-tolerant applications.
Akka is Open Source and available under the Apache 2 License.
I gave this presentation to my coworkers recently. Unfortunately, the animations done translate to PDF so it's a tad sucky, but the main content is there.
Building Reactive Systems with Akka (in Java 8 or Scala)Jonas Bonér
Learn how to build Reactive Systems with Akka. Examples in both Java 8 and Scala.
Abstract:
The demands and expectations for applications have changed dramatically in recent years. Applications today are deployed on a wide range of infrastructure; from mobile devices up to thousands of nodes running in the cloud—all powered by multi-core processors. They need to be rich and collaborative, have a real-time feel with millisecond response time and should never stop running. Additionally, modern applications are a mashup of external services that need to be consumed and composed to provide the features at hand. We are seeing a new type of applications emerging to address these new challenges—these are being called Reactive Applications.
In this talk we will introduce you to Akka and discuss how it can help you deliver on the four key traits of Reactive; Responsive, Resilient, Elastic and Message-Driven. We will start with the basics of Akka and work our way towards some of its more advanced modules such as Akka Cluster and Akka Persistence—all driven through code and practical examples.
Introduction to Akka 2. Explains what Akka's actors are all about and how to utilize them to write scalable and fault-tolerant systems.
Talk given at JavaZone 2012.
Since 2014, Typesafe has been actively contributing to the Apache Spark project, and has become a certified development support partner of Databricks, the company started by the creators of Spark. Typesafe and Mesosphere have forged a partnership in which Typesafe is the official commercial support provider of Spark on Apache Mesos, along with Mesosphere’s Datacenter Operating Systems (DCOS).
In this webinar with Iulian Dragos, Spark team lead at Typesafe Inc., we reveal how Typesafe supports running Spark in various deployment modes, along with the improvements we made to Spark to help integrate backpressure signals into the underlying technologies, making it a better fit for Reactive Streams. He also show you the functionalities at work, and how to make it simple to deploy to Spark on Mesos with Typesafe.
We will introduce:
Various deployment modes for Spark: Standalone, Spark on Mesos, and Spark with Mesosphere DCOS
Overview of Mesos and how it relates to Mesosphere DCOS
Deeper look at how Spark runs on Mesos
How to manage coarse-grained and fine-grained scheduling modes on Mesos
What to know about a client vs. cluster deployment
A demo running Spark on Mesos
Everyone in the Scala world is using or looking into using Akka for low-latency, scalable, distributed or concurrent systems. I'd like to share my story of developing and productionizing multiple Akka apps, including low-latency ingestion and real-time processing systems, and Spark-based applications.
When does one use actors vs futures?
Can we use Akka with, or in place of, Storm?
How did we set up instrumentation and monitoring in production?
How does one use VisualVM to debug Akka apps in production?
What happens if the mailbox gets full?
What is our Akka stack like?
I will share best practices for building Akka and Scala apps, pitfalls and things we'd like to avoid, and a vision of where we would like to go for ideal Akka monitoring, instrumentation, and debugging facilities. Plus backpressure and at-least-once processing.
Presentation on the principles, philosophy and a few applications of object oriented programming along with a few pointers on how to effectively code. Presented at a session aimed at undergrad computer science students at the University of Pune.
Present along with Mr. Anirudh Tomer and Mr. Toshish Jawale.
This presentation talks about the Dependency Injection design principle, providing an overview of the pattern and its benefits while showing examples on how to apply it using Autofac, a specific dependency injection tool for .NET development.
Autofac: http://code.google.com/p/autofac/
A book on DI: http://www.manning.com/seemann/
My session at AnDevCon, April 2014, Boston, MA
The session gives an introduction to using the Java Native Interface (JNI) in Java, and in particular in the Android Platform. The session then covers the use of the Native Development Kit (NDK) for developing Android applications.
@todo update description
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...Alessandro Molina
Kajiki si an XML/HTML template engine born as a replacement for Genshi with specific improvements for speed and an easier inheritance system based on blocks.
Docker is an open platform for developers and system administrators to build, ship and run distributed applications. Using Docker, companies in Jordan have been able to build powerful system architectures that allow speeding up delivery, easing deployment processes and at the same time cutting major hosting costs.
George Khoury shares his experience at Salalem in building flexible and cost effective architectures using Docker and other tools for infrastructure orchestration. The result allows them to easily and quickly move between different cloud providers.
Dart is a new language for the web, enabling you to write JavaScript on a secure and manageable way. No need to worry about "JavaScript: The bad parts".
This presentation concentrates on the developer experience converting from the Java based GWT to Dart.
Joomla architecture - what happened behind the scenes.
Did you always wanted to know what happened behind the scenes of Joomla code? Come and find what triggered down to up with real life scenarios, like MVC architecture, Plugin design pattern, how getDBO bring me the database instance and much more.
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
Ever wondered how IDE’s are built? In this talk, we’ll skip the marketing bit and dive into the architecture and implementation of JetBrains Rider. We’ll look at how and why we have built (and open sourced) a reactive protocol, and how the IDE uses a “microservices” architecture to communicate with the debugger, Roslyn, a WPF renderer and even other tools like Unity3D. We’ll explore how things are wired together, both in-process and across those microservices. Let’s geek out!
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInDataGetInData
If you want to stay up to date, subscribe to our newsletter here: https://bit.ly/3tiw1I8
Presentation from the performance given by Mariusz during the Data Science Summit ML Edition.
Author: Mariusz Strzelecki
Linkedin: https://www.linkedin.com/in/mariusz-strzelecki/
___
Company:
Getindata is a company founded in 2014 by ex-Spotify data engineers. From day one our focus has been on Big Data projects. We bring together a group of best and most experienced experts in Poland, working with cloud and open-source Big Data technologies to help companies build scalable data architectures and implement advanced analytics over large data sets.
Our experts have vast production experience in implementing Big Data projects for Polish as well as foreign companies including i.a. Spotify, Play, Truecaller, Kcell, Acast, Allegro, ING, Agora, Synerise, StepStone, iZettle and many others from the pharmaceutical, media, finance and FMCG industries.
https://getindata.com
Similar to Effective Scala: Programming Patterns (20)
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
2. The most of the patterns you've got
used to in a traditional OO-languages
(C++, Java, C#) are just language
constructs in a functional languages
3. The key principle behind the most
of techniques is functional languages is
composition - ability to build assets
that can be reused in different contexts
unknown at the time they created
5. What if you wanted to add new method
for Int?
In Java you would write a wrapper class and use it everywhere
you want your new Int on steroids.
In Scala you would use implicit conversions.
object RichInt {
implicit def intToRichInt(i: Int) = new RichInt(i)
}
class RichInt(private val value: Int) {
def minutes = value + " minutes"
}
// Usage example
import RichInt._
println(10 minutes) //println(intToRichInt(10).minutes)
6. Pimp My Library
● Simple
● Less boilerplate then ad-hoc conversion
● Can be controlled with scoping
8. Cell is an object behaving closely like a
normal variable
Implementation details are hidden from end user
Scala has two features in possesion helping us to implement
such a semi-variable:
1. "First class object" functions
var f: Option[() => Int] = Some(() => 1)
2. Syntactic sugar for update and apply
x() == x.apply()
and
x(<arguments>*) = y == x.update(<arguments>*, y)
9. Let's design lazy value using Cell pattern
class Lazy[T] { private var v: Option[T] = None private var t: Option[() => T] =
None def update(t: => T) { this.t = Some(t _) v = None } def apply() = { if(v.isEmpty)
v = Some(t.get()) v.get } } val l = new Lazy[Int] l() = { println("Evaluated"); 1} println
("Before evaluated") println(l()) l() = 2 println(l())
10. Cell actually is
● Simple once again
● Used similar to a variable thanks to syntactic sugar
● Still an object
12. Unified factory
import java.util.Date trait Vendor[T] { def vend: T } implicit object
DateVendor extends Vendor[Date] { def vend = new Date } object
Vendor { def vend[T](implicit vendor: Vendor[T]):T = vendor.vend } val
date = Vendor.vend[Date]
This guy is like a one man band.
Tell him a type you wanna play with and he'll hand you off an
instance.
13. Type class
● Extendable through composition
● Abstracts capabilities from data
● Connects different class hierarchies together
● Controlable with scoping
15. OMG, we're in J2EE environment
Following dreaded pattern can often be seen in IOC container
environment(well at least when it's a bad one)
class DBDriver class Bean { private var driver: DBDriver = null def getDriver() = driver def setDriver(driver:
DBDriver) { this.driver = driver } } class AnotherBeanFromAnotherParty { private var driver: DBDriver = null
def getDriver() = driver def setDriver(driver:DBDriver) { this.driver = driver } } object Bean extends Bean {
setDriver(new DBDriver) } object AnotherBeanFromAnotherParty extends AnotherBeanFromAnotherParty {
setDriver(new DBDriver) }
Here is how we work this around with structural typing
def extractDriver(bean: { def getDriver(): DBDriver }): DBDriver = bean.getDriver() extractDriver
(Bean) extractDriver(AnotherBeanFromAnotherParty)
16. Structural typing
● Actually a workaround for poorly designed architecture
● A typesafe workaround
● Follows don't repeat yourself
18. ..."Dependency Injection" is a 25-dollar
term for a 5-cent concept... Dependency
injection means giving an object its instance
variables...
James Shore
19. What do you need dependency injection
for?
● reduces coupling between
components
● simplifies configuration of an
assembly
○ useful for unit testing
20. IoC containers take a simple, elegant, and
useful concept, and make it something you
have to study for two days with a 200-page
manual
Joel Spolsky
21. ● in Scala you don't need any DI
framework - forget Spring and Guice
● you make DI with mixins & self-type
annotations and no boilerplate
23. What's so cool in Cake pattern?
● It's not a framework, thus any IDE
supports it out-of-box
● If a dependency is missing, compiler will
immediately let you know about it
25. The brain of an average human is used by
only 10% through the lifetime
The type system is used by an
average programmer by only 10% of
its power
26. Phantom types is a simple yet
powerful way to use the type
system more effectively
2 facts about phantom
types:
● never instantiated
● used only to construct other
types
27. Let's say, we need a data type to represent
the form data extracted from an HTTP
request:
case class FormData[+T <: Data]
(data: Map[String, String])
trait Data
trait Validated extends Data
trait Unvalidated extends Data
Validated and Unvalidated are phantom
types
28. trait Form {
val readFormData: HttpServletRequest => FormData
[Unvalidated]
val validate: FormData[Unvalidated] => FormData
[Validated]
val printFormData: FormData[Validated] => Any
}
(readFormData andThen validate andThen printFormData)
(request)
(readFormData andThen printFormData)(request) // FAILS!!!