Specs2
-
Upload
eric-torreborre -
Category
Technology
-
view
981 -
download
0
description
Transcript of Specs2
Go functional!
Shame
Mutability
Concurrency
Acceptance
Why
The idea
User
DesignProgram
Go Functional!
But what
is it?!
Referential transparency
Immutabili
ty
behavior
pipelined
FPemerg
entbehavior
Processing data structures
OO
Why
The idea
User
DesignProgram
Starting point
Nesting
Precedence:+!^
FormattingText
Example
Text
Example
Example
Formatting
pbrendt, t(i)bt, bt(i)
acceptance
Context
doBefore
withDb.apply(e2)
Why
The idea
User
DesignProgram
Run
execute
levels
select
sequence
arguments
statistics
to text
to html
Laziness vs evaluation
Iterating
Traverse
A datastructure to
traversethe
accumulation
the mapping
Applicative magic?
Lots of instances:• State• List• Monad• Monoid
simple
composable Type inference is hard,Let’s go
shopping!
Reduceraggregation
“parallel” composition
mapping
specs2 reducers:• Levels• Statistics• Arguments• Text• Html
Why
The idea
User
DesignProgram
Trees
Text
Example 1
Example 2
SuiteDescript
ion
Test Descriptio
n 1
Test Descriptio
n 2
SuiteDescription
fChildren = TD1, TD2
TreeLoc
TreeLoc
<h1/>
<h2/> <h2/>
<body>
<h2>part 1</h2><h2>part 2</h2>
<h1>Title 1</h1>
</body>
Anti-XMLThe non-violent solution
Concurrency
a concurrent task
=> Promise[Seq[ExecutedFragment]]
Exceptions
Exceptions
Exceptions
Mocks
<h1/>
MutabilityBack fo
r
good
Nothing here!
Throws exception
ConfigurationPart of the flow
named parameters + defaults
nested ‘record’
ConfigurationImplicits
implicit arguments
default value
Conclusion
• Reliability• Concurrency• Composition• Less mocks• val/vars
• DSL• Type inference• Learning curve