SlideShare a Scribd company logo
1 of 101
Download to read offline
It’s the end of 
Design Patterns 
as we know it 
(and I feel fine) 
Today: 
Introducing Monads 
Luiz Borba 
http://borba.blog.br
Part 1 
Deconstructing 
Design Patterns
1994
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
PHP (95)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
PHP (95)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
DESKTOP 
PHP (95)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
WEB 
PHP (95)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
PHP (95)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88) 
PHP (95)
" 
I always knew that one day 
Smalltalk 
would replace Java. 
I just didn’t know 
it would be called 
Ruby 
" 
(Kent Beck)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88)
It’s the 
Mainstream, 
stupid!
Always 
Controversial
Ralph Johnson and Singleton
Are 
Design Patterns 
missing languages features?
Are 
Design Patterns 
how languages evolve? 
(Jeff Atwood)
COBOL (61) 
FORTRAN (57) 
CLIPPER (85) 
C (72) 
SMALLTALK (72) 
C++ (83) 
PASCAL (86) 
LISP (58) 
PERL (87) 
MS BASIC (75) 
OBJECT PASCAL (95) 
ML (73) 
HASKELL (90) 
JAVA (95) RUBY (95) 
PYTHON (91) 
ALGOL (58) 
POWERBUILDER (92) 
BASIC (64) 
VISUAL BASIC (91) 
SQLWINDOWS (88)
2010
imperative languages 
Java 
C 
Fortran 
C++ 
add 
abstractions
subtract 
abstractions 
Lisp 
ML 
Haskell 
functional languages 
imperative languages 
Java 
C 
Fortran 
C++ 
add 
abstractions
subtract 
abstractions 
Lisp 
ML 
Haskell 
functional languages 
imperative languages 
Java 
C 
Fortran 
C++ 
add 
abstractions 
Scala 
Java 8 
C# 
F# 
hybrid languages
Haskell: 
[x | x <- xs, x < 10]
Haskell: 
[x | x <- xs, x < 10] 
C#: 
from x in xs where x < 10 select x;
Haskell: 
[x | x <- xs, x < 10] 
C#: 
from x in xs where x < 10 select x; 
Java 8: 
xs.stream().filter(x -> x < 10)
2014
Erlang 
Javascript 
Java 8 
Swift 
Objective-C 
C# 
C 
PHP 
Python 
Ruby 
Dart 
Elixir 
Coffeescript 
Scala 
Go 
Clojure 
Rust 
Groovy 
C++ 
Haskell 
F#
Erlang 
Javascript 
Java 8 
Swift 
Objective-C 
C# 
C 
PHP 
Python 
Ruby 
Dart 
Elixir 
Coffeescript 
Scala 
Go 
Clojure 
Rust 
Groovy 
C++ 
Haskell 
F#
We need to rewrite the 
design patterns book
Part 2 
Introducing Monads
Once you understand 
Monadsfor yourself 
you lose the ability 
to explain them to others 
(Douglas Crockford) 
" 
"
A Monad is just 
a monoid in the 
category of 
endofunctors
WTF?
WARM UP
What’s a 
Stack?
Value
Operations
Rules 
+ = 
stack.push(value).top == value 
stack.isEmpty == true 
stack.push(value).isEmpty == false
and.. 
We can implement them 
however we like 
We can use them without 
knowing their implementation
What’s a 
Queue?
What are 
Stack & 
Queue?
ABSTRACT 
TYPES 
DATA
Javascript 
Promises
Asynchronous 
programming is 
becoming the norm in 
modern, 
connected applications" 
(Anders Hejlsberg) 
"
var FS = require('fs'), 
request = require('request'); 
function getResults(pathToFile, callback) { 
FS.readFile(pathToFile, 'utf8', function(err, data) { 
if (err) return callback(err); 
var response1, response2; 
request.post('http://service1.example.com?data=' + data), function(err, response, body) { 
if(err) return callback(err); 
response1 = response; 
next(); 
}); 
request.post('http://service2.example.com?data=' + data), function(err, response, body) { 
if(err) return callback(err); 
response2 = response; 
next(); 
}); 
function next(){ 
if(response1 && response2){ 
callback(null, [response1, response2]); 
} 
} 
}); 
}
asyncCall(function(err, data1){ 
if(err) return callback(err); 
anotherAsyncCall(function(err2, data2){ 
if(err2) return calllback(err2); 
oneMoreAsyncCall(function(err3, data3){ 
if(err3) return callback(err3); 
// are we done yet? 
}); 
}); 
});
asyncCall() 
.then(function(data1){ 
// do something... 
return anotherAsyncCall(); 
}) 
.then(function(data2){ 
// do something... 
return oneMoreAsyncCall(); 
}) 
.then(function(data3){ 
// the third and final async response 
}) 
.fail(function(err) { 
// handle any error resulting from any of the above calls 
}) 
.done();
var promise = new Promise(initialFunction) 
var anotherPromise = promise.then(functionB) 
var yetAnotherPromise = anotherPromise.then(functionC) 
...
var promise = new Promise(initialFunction) 
var anotherPromise = promise.then(functionB) 
var yetAnotherPromise = anotherPromise.then(functionC) 
...
var promise = new Promise(initialFunction) 
var anotherPromise = promise.then(functionB) 
var yetAnotherPromise = anotherPromise.then(functionC) 
...
Java 8 
Optional
String version = computer 
.getSoundcard() 
.getUSB() 
.getVersion();
String version = "UNKNOWN"; 
if(computer != null){ 
Soundcard soundcard = computer.getSoundcard(); 
if(soundcard != null){ 
USB usb = soundcard.getUSB(); 
if(usb != null){ 
version = usb.getVersion(); 
} 
} 
}
String name = Optional.of(computer) 
.map(Computer::getSoundcard) 
.map(Soundcard::getUSB) 
.map(USB::getVersion) 
.orElse("UNKNOWN");
String name = Optional.of(computer) 
.map(Computer::getSoundcard) 
.map(Soundcard::getUSB) 
.map(USB::getVersion) 
.orElse("UNKNOWN");
String name = Optional.of(computer) 
.map(Computer::getSoundcard) 
.map(Soundcard::getUSB) 
.map(USB::getVersion) 
.orElse("UNKNOWN");
Promises and Optional 
are Monads
A Monad is a structure 
that puts a value in a 
computational context
Monad<A> unit(A a)
Monad<A> unit(A a)
Monad<A> unit(A a)
Monad<B> bind(M<A> ma, 
Function<A, M<B>> f)
Monad<B> bind(M<A> ma, 
Function<A, M<B>> f)
Monad<B> bind(M<A> ma, 
Function<A, M<B>> f)
Monad: 
Value, Operations and Rules 
unit(x) = Monad x 
unit(x).bind(f) = Monad f(x) 
unit(x).bind(f).bind(g) = Monad g(f(x))
Haskell 
I/O
Unit & Bind in Haskell 
return :: Monad m => a -> m a 
(>>=) :: Monad m => m a -> (a -> m b) -> m b 
(>>) :: Monad m => m a -> m b -> m b
I/O Example 
main :: IO () 
main = 
putStrLn "What is your name?" >> 
getLine >>= 
name -> putStrLn ("Hello, " ++ name)
Sequence 
main :: IO () 
main = do 
putStrLn "What is your name?" 
name <- getLine 
putStrLn ("Hello, " ++ name)
What is that? 
main :: IO () 
main = do 
putStrLn "What is your name?" 
name <- getLine 
putStrLn ("Hello, " ++ name)
Imperative code 
in functional style
PARADIGM MIX, 
stupid! 
It’s the
One more thing…
Accidental Monad 
BuilderResult<Group> groupBuilder = new Builder<Group>(Group.class) 
.daoContext(daoContext) 
.user(loginUser) 
.comments(body.getCreateComments()) 
.set(Field.name).with(name).validations(required(), unique()) 
.set(Field.owners).with(ownerIds).converting(convertToOwner()) 
.validations(required()) 
.set(Field.description).with(body.getDesc()).withoutValidation() 
.build();
"Six of one or half 
dozen of the other"
Set<PersistenceEventListener> result = new HashSet<>(); 
for (String channel: channels) { 
List<PersistenceEventListener> channelListeners = 
listenersPerChannel.get(channel); 
if (channelListeners != null) { 
result.addAll(channelListeners); 
} 
} 
return result; 
X 
return listenersPerChannel.entrySet().stream() 
.filter(e -> Arrays.asList(channels).contains(e.getKey())) 
.map(e -> e.getValue()) 
.flatMap(l -> l.stream()) 
.collect(Collectors.toSet());
Moral of the Story
Languages are evolving
Programmers must evolve 
along with the languages and 
enjoy learning new things
It’s the end of Design Patterns 
as we know it (and I feel fine) 
Thank you! 
Luiz Borba 
http://borba.blog.br

More Related Content

What's hot

JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival GuideGiordano Scalzo
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)lichtkind
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good PartsKent Ohashi
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureWilton Silva
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talkJohn Stevenson
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеSergey Platonov
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Oky Firmansyah
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnMoriyoshi Koizumi
 
Large Scale JavaScript with TypeScript
Large Scale JavaScript with TypeScriptLarge Scale JavaScript with TypeScript
Large Scale JavaScript with TypeScriptOliver Zeigermann
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scalaRuslan Shevchenko
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clustersBurak Himmetoglu
 
Clojurian Conquest
Clojurian ConquestClojurian Conquest
Clojurian ConquestKent Ohashi
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Sergey Platonov
 

What's hot (20)

JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
 
JavaScript Patterns
JavaScript PatternsJavaScript Patterns
JavaScript Patterns
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)
 
R/C++ talk at earl 2014
R/C++ talk at earl 2014R/C++ talk at earl 2014
R/C++ talk at earl 2014
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good Parts
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with Clojure
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)Introduction to modern c++ principles(part 1)
Introduction to modern c++ principles(part 1)
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
 
Large Scale JavaScript with TypeScript
Large Scale JavaScript with TypeScriptLarge Scale JavaScript with TypeScript
Large Scale JavaScript with TypeScript
 
How to write Ruby extensions with Crystal
How to write Ruby extensions with CrystalHow to write Ruby extensions with Crystal
How to write Ruby extensions with Crystal
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clusters
 
Clojurian Conquest
Clojurian ConquestClojurian Conquest
Clojurian Conquest
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++
 
Clojure intro
Clojure introClojure intro
Clojure intro
 

Similar to It's the end of design patterns as we know it (and i feel fine)

Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойSigma Software
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and MonoidsHugo Gävert
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011Thadeu Russo
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingGarth Gilmour
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVMJarek Ratajski
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)David de Boer
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-CNissan Tsafrir
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Davide Cerbo
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonAlex Payne
 
Writing Hadoop Jobs in Scala using Scalding
Writing Hadoop Jobs in Scala using ScaldingWriting Hadoop Jobs in Scala using Scalding
Writing Hadoop Jobs in Scala using ScaldingToni Cebrián
 

Similar to It's the end of design patterns as we know it (and i feel fine) (20)

Столпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай МозговойСтолпы функционального программирования для адептов ООП, Николай Мозговой
Столпы функционального программирования для адептов ООП, Николай Мозговой
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
 
Monadologie
MonadologieMonadologie
Monadologie
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-C
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
Eta
EtaEta
Eta
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Writing Hadoop Jobs in Scala using Scalding
Writing Hadoop Jobs in Scala using ScaldingWriting Hadoop Jobs in Scala using Scalding
Writing Hadoop Jobs in Scala using Scalding
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Kotlin Coroutines and Rx
Kotlin Coroutines and RxKotlin Coroutines and Rx
Kotlin Coroutines and Rx
 

More from Luiz Borba

Novas ferramentas para analise de dados
Novas ferramentas para analise de dadosNovas ferramentas para analise de dados
Novas ferramentas para analise de dadosLuiz Borba
 
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...Luiz Borba
 
Desconstruindo EJB
Desconstruindo EJBDesconstruindo EJB
Desconstruindo EJBLuiz Borba
 
Arquitetura pragmática
Arquitetura pragmáticaArquitetura pragmática
Arquitetura pragmáticaLuiz Borba
 
O triunfo dos nerds
O triunfo dos nerdsO triunfo dos nerds
O triunfo dos nerdsLuiz Borba
 
O ciclo da vida
O ciclo da vidaO ciclo da vida
O ciclo da vidaLuiz Borba
 
As coisas mudam
As coisas mudamAs coisas mudam
As coisas mudamLuiz Borba
 
Merda Acontece
Merda AconteceMerda Acontece
Merda AconteceLuiz Borba
 
Build 2013: O que vi por lá
Build 2013: O que vi por láBuild 2013: O que vi por lá
Build 2013: O que vi por láLuiz Borba
 
11 historias e 1 segredo
11 historias e 1 segredo11 historias e 1 segredo
11 historias e 1 segredoLuiz Borba
 
Coisas que levei um tempo para aprender
Coisas que levei um tempo para aprenderCoisas que levei um tempo para aprender
Coisas que levei um tempo para aprenderLuiz Borba
 
Windows 8 a nova corrida do ouro
Windows 8 a nova corrida do ouroWindows 8 a nova corrida do ouro
Windows 8 a nova corrida do ouroLuiz Borba
 
Assuntos aleatorios que podem mudar sua vida
Assuntos aleatorios que podem mudar sua vidaAssuntos aleatorios que podem mudar sua vida
Assuntos aleatorios que podem mudar sua vidaLuiz Borba
 
What i dont know about startups
What i dont know about startupsWhat i dont know about startups
What i dont know about startupsLuiz Borba
 
Todas as coisas que todo programador não pode deixar de saber
Todas as coisas que todo programador não pode deixar de saberTodas as coisas que todo programador não pode deixar de saber
Todas as coisas que todo programador não pode deixar de saberLuiz Borba
 
Por que voce precisa (re)aprender linguagens funcionais
Por que voce precisa (re)aprender linguagens funcionaisPor que voce precisa (re)aprender linguagens funcionais
Por que voce precisa (re)aprender linguagens funcionaisLuiz Borba
 
TDD Direto das Trincheiras versao 2
TDD Direto das Trincheiras versao 2TDD Direto das Trincheiras versao 2
TDD Direto das Trincheiras versao 2Luiz Borba
 
TDD direto das trincheiras
TDD direto das trincheirasTDD direto das trincheiras
TDD direto das trincheirasLuiz Borba
 

More from Luiz Borba (20)

Novas ferramentas para analise de dados
Novas ferramentas para analise de dadosNovas ferramentas para analise de dados
Novas ferramentas para analise de dados
 
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...
Os paradoxos de Blub, Python, a décima lei de Greenspun e porque você deveria...
 
Desconstruindo EJB
Desconstruindo EJBDesconstruindo EJB
Desconstruindo EJB
 
Arquitetura pragmática
Arquitetura pragmáticaArquitetura pragmática
Arquitetura pragmática
 
O triunfo dos nerds
O triunfo dos nerdsO triunfo dos nerds
O triunfo dos nerds
 
O ciclo da vida
O ciclo da vidaO ciclo da vida
O ciclo da vida
 
As coisas mudam
As coisas mudamAs coisas mudam
As coisas mudam
 
Merda Acontece
Merda AconteceMerda Acontece
Merda Acontece
 
Build 2013: O que vi por lá
Build 2013: O que vi por láBuild 2013: O que vi por lá
Build 2013: O que vi por lá
 
11 historias e 1 segredo
11 historias e 1 segredo11 historias e 1 segredo
11 historias e 1 segredo
 
Coisas que levei um tempo para aprender
Coisas que levei um tempo para aprenderCoisas que levei um tempo para aprender
Coisas que levei um tempo para aprender
 
O futuro
O futuroO futuro
O futuro
 
Windows 8 a nova corrida do ouro
Windows 8 a nova corrida do ouroWindows 8 a nova corrida do ouro
Windows 8 a nova corrida do ouro
 
Assuntos aleatorios que podem mudar sua vida
Assuntos aleatorios que podem mudar sua vidaAssuntos aleatorios que podem mudar sua vida
Assuntos aleatorios que podem mudar sua vida
 
Startup tools
Startup toolsStartup tools
Startup tools
 
What i dont know about startups
What i dont know about startupsWhat i dont know about startups
What i dont know about startups
 
Todas as coisas que todo programador não pode deixar de saber
Todas as coisas que todo programador não pode deixar de saberTodas as coisas que todo programador não pode deixar de saber
Todas as coisas que todo programador não pode deixar de saber
 
Por que voce precisa (re)aprender linguagens funcionais
Por que voce precisa (re)aprender linguagens funcionaisPor que voce precisa (re)aprender linguagens funcionais
Por que voce precisa (re)aprender linguagens funcionais
 
TDD Direto das Trincheiras versao 2
TDD Direto das Trincheiras versao 2TDD Direto das Trincheiras versao 2
TDD Direto das Trincheiras versao 2
 
TDD direto das trincheiras
TDD direto das trincheirasTDD direto das trincheiras
TDD direto das trincheiras
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

It's the end of design patterns as we know it (and i feel fine)

  • 1. It’s the end of Design Patterns as we know it (and I feel fine) Today: Introducing Monads Luiz Borba http://borba.blog.br
  • 2. Part 1 Deconstructing Design Patterns
  • 4. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) PHP (95)
  • 5. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) PHP (95)
  • 6. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) DESKTOP PHP (95)
  • 7. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) WEB PHP (95)
  • 8. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) PHP (95)
  • 9. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88) PHP (95)
  • 10. " I always knew that one day Smalltalk would replace Java. I just didn’t know it would be called Ruby " (Kent Beck)
  • 11. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88)
  • 14.
  • 15.
  • 16. Ralph Johnson and Singleton
  • 17. Are Design Patterns missing languages features?
  • 18. Are Design Patterns how languages evolve? (Jeff Atwood)
  • 19.
  • 20.
  • 21.
  • 22. COBOL (61) FORTRAN (57) CLIPPER (85) C (72) SMALLTALK (72) C++ (83) PASCAL (86) LISP (58) PERL (87) MS BASIC (75) OBJECT PASCAL (95) ML (73) HASKELL (90) JAVA (95) RUBY (95) PYTHON (91) ALGOL (58) POWERBUILDER (92) BASIC (64) VISUAL BASIC (91) SQLWINDOWS (88)
  • 23. 2010
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. imperative languages Java C Fortran C++ add abstractions
  • 35. subtract abstractions Lisp ML Haskell functional languages imperative languages Java C Fortran C++ add abstractions
  • 36. subtract abstractions Lisp ML Haskell functional languages imperative languages Java C Fortran C++ add abstractions Scala Java 8 C# F# hybrid languages
  • 37.
  • 38.
  • 39. Haskell: [x | x <- xs, x < 10]
  • 40. Haskell: [x | x <- xs, x < 10] C#: from x in xs where x < 10 select x;
  • 41. Haskell: [x | x <- xs, x < 10] C#: from x in xs where x < 10 select x; Java 8: xs.stream().filter(x -> x < 10)
  • 42. 2014
  • 43. Erlang Javascript Java 8 Swift Objective-C C# C PHP Python Ruby Dart Elixir Coffeescript Scala Go Clojure Rust Groovy C++ Haskell F#
  • 44. Erlang Javascript Java 8 Swift Objective-C C# C PHP Python Ruby Dart Elixir Coffeescript Scala Go Clojure Rust Groovy C++ Haskell F#
  • 45.
  • 46. We need to rewrite the design patterns book
  • 48.
  • 49. Once you understand Monadsfor yourself you lose the ability to explain them to others (Douglas Crockford) " "
  • 50. A Monad is just a monoid in the category of endofunctors
  • 51. WTF?
  • 52.
  • 55. Value
  • 57. Rules + = stack.push(value).top == value stack.isEmpty == true stack.push(value).isEmpty == false
  • 58. and.. We can implement them however we like We can use them without knowing their implementation
  • 60. What are Stack & Queue?
  • 63. Asynchronous programming is becoming the norm in modern, connected applications" (Anders Hejlsberg) "
  • 64. var FS = require('fs'), request = require('request'); function getResults(pathToFile, callback) { FS.readFile(pathToFile, 'utf8', function(err, data) { if (err) return callback(err); var response1, response2; request.post('http://service1.example.com?data=' + data), function(err, response, body) { if(err) return callback(err); response1 = response; next(); }); request.post('http://service2.example.com?data=' + data), function(err, response, body) { if(err) return callback(err); response2 = response; next(); }); function next(){ if(response1 && response2){ callback(null, [response1, response2]); } } }); }
  • 65. asyncCall(function(err, data1){ if(err) return callback(err); anotherAsyncCall(function(err2, data2){ if(err2) return calllback(err2); oneMoreAsyncCall(function(err3, data3){ if(err3) return callback(err3); // are we done yet? }); }); });
  • 66. asyncCall() .then(function(data1){ // do something... return anotherAsyncCall(); }) .then(function(data2){ // do something... return oneMoreAsyncCall(); }) .then(function(data3){ // the third and final async response }) .fail(function(err) { // handle any error resulting from any of the above calls }) .done();
  • 67. var promise = new Promise(initialFunction) var anotherPromise = promise.then(functionB) var yetAnotherPromise = anotherPromise.then(functionC) ...
  • 68. var promise = new Promise(initialFunction) var anotherPromise = promise.then(functionB) var yetAnotherPromise = anotherPromise.then(functionC) ...
  • 69. var promise = new Promise(initialFunction) var anotherPromise = promise.then(functionB) var yetAnotherPromise = anotherPromise.then(functionC) ...
  • 71. String version = computer .getSoundcard() .getUSB() .getVersion();
  • 72. String version = "UNKNOWN"; if(computer != null){ Soundcard soundcard = computer.getSoundcard(); if(soundcard != null){ USB usb = soundcard.getUSB(); if(usb != null){ version = usb.getVersion(); } } }
  • 73. String name = Optional.of(computer) .map(Computer::getSoundcard) .map(Soundcard::getUSB) .map(USB::getVersion) .orElse("UNKNOWN");
  • 74. String name = Optional.of(computer) .map(Computer::getSoundcard) .map(Soundcard::getUSB) .map(USB::getVersion) .orElse("UNKNOWN");
  • 75. String name = Optional.of(computer) .map(Computer::getSoundcard) .map(Soundcard::getUSB) .map(USB::getVersion) .orElse("UNKNOWN");
  • 76. Promises and Optional are Monads
  • 77. A Monad is a structure that puts a value in a computational context
  • 81. Monad<B> bind(M<A> ma, Function<A, M<B>> f)
  • 82. Monad<B> bind(M<A> ma, Function<A, M<B>> f)
  • 83. Monad<B> bind(M<A> ma, Function<A, M<B>> f)
  • 84. Monad: Value, Operations and Rules unit(x) = Monad x unit(x).bind(f) = Monad f(x) unit(x).bind(f).bind(g) = Monad g(f(x))
  • 86. Unit & Bind in Haskell return :: Monad m => a -> m a (>>=) :: Monad m => m a -> (a -> m b) -> m b (>>) :: Monad m => m a -> m b -> m b
  • 87. I/O Example main :: IO () main = putStrLn "What is your name?" >> getLine >>= name -> putStrLn ("Hello, " ++ name)
  • 88. Sequence main :: IO () main = do putStrLn "What is your name?" name <- getLine putStrLn ("Hello, " ++ name)
  • 89. What is that? main :: IO () main = do putStrLn "What is your name?" name <- getLine putStrLn ("Hello, " ++ name)
  • 90. Imperative code in functional style
  • 91. PARADIGM MIX, stupid! It’s the
  • 92.
  • 93.
  • 95. Accidental Monad BuilderResult<Group> groupBuilder = new Builder<Group>(Group.class) .daoContext(daoContext) .user(loginUser) .comments(body.getCreateComments()) .set(Field.name).with(name).validations(required(), unique()) .set(Field.owners).with(ownerIds).converting(convertToOwner()) .validations(required()) .set(Field.description).with(body.getDesc()).withoutValidation() .build();
  • 96. "Six of one or half dozen of the other"
  • 97. Set<PersistenceEventListener> result = new HashSet<>(); for (String channel: channels) { List<PersistenceEventListener> channelListeners = listenersPerChannel.get(channel); if (channelListeners != null) { result.addAll(channelListeners); } } return result; X return listenersPerChannel.entrySet().stream() .filter(e -> Arrays.asList(channels).contains(e.getKey())) .map(e -> e.getValue()) .flatMap(l -> l.stream()) .collect(Collectors.toSet());
  • 98. Moral of the Story
  • 100. Programmers must evolve along with the languages and enjoy learning new things
  • 101. It’s the end of Design Patterns as we know it (and I feel fine) Thank you! Luiz Borba http://borba.blog.br