Presented at JAX London 2013
tl;dr - How will the everyday developer cope with Java 8’s Language changes?
Java 8 will ship with a powerful new abstraction - Lambda Expressions (aka Closures) and a completely retooled set of Collections libraries. In addition interfaces have changed through the addition of default and static methods. The ongoing debate as to whether Java should include such language changes has resulted in many vocal opinions being espoused. Sadly few of these opinions have been backed up by practical experimentation and experience. - Are these opinions just myths?
2. the critical design tool for software
development is a mind well educated in
design principles. It is not ... technology.
Craig Larman
3. Who am I?
Currently work at jClarity
Focus on Performance Tuning
Adopt a JSR (Date and Time + Lambdas)
Impending O'Reilly book on Lambda
Expressions in Java 8.
4. Talk Structure
Why am I talking about this?
Intro to Lambda Expressions
Beyond the Myths
Functional Thinking
47. Very little Testing
Maybe ...
a reflection on popularity of TDD
spikes are good for learning
unfamiliarity with testing lambdas
48. How do I test this?
ls.tem)
itsra(
.a( - 10/Mt.el1+Mt.o()+Mt.tn(,x)
mpx > .
ahci(
ahpwx
ahaa2y ))
.olc(oit);
clettLs()
49. Approach 1: Test
surrounding method
Don't test the lambda
Test the method its surrounded by
Works well for simple lambdas
50. Approach 2: Extract
Method
dul cmlxucindul x {
obe opeFnto(obe )
rtr 10/Mt.el1+Mt.o()+Mt.tn(,x)
eun .
ahci(
ahpwx
ahaa20 );
}
ls.tem)
itsra(
.a(hs:opeFnto)
mpti:cmlxucin
.olc(oit);
clettLs()
51. Mistake: debugging
/ Sras
/ tem
ls.tem)
itsra(
.itrfleigucin
fle(itrnFnto)
.a(apnFnto)
mpmpigucin
.olc(oit);
clettLs()
/ Y od frlo
/ e le o op
Ls<a>br =nwAryit>)
itBr as
e raLs<(;
fr(o eeet:ls){
o Fo lmn
it
i (itrnFnto(lmn){
f fleigucineeet
Brrsl =mpigucineeet;
a eut
apnFnto(lmn)
br.d(eut;
asadrsl)
}
}
55. Compiler Error
jv:rfrnet cmaigi abgosbt
aa eeec o oprn s miuu oh
mto
ehd
<>oprn(aaui.ucinTItucin ?sprT)
Tcmaigjv.tlfnto.onFnto<
ue >
i jv.tlCmaao admto
n aaui.oprtr n ehd
<,>oprn(aaui.ucinFnto<?sprT?etnsU)
TUcmaigjv.tlfnto.ucin
ue , xed >
i jv.tlCmaao mth
n aaui.oprtr ac
56. What happened?
/ Gnrcojc vrat
/ eei bet ain
pbi sai <,UetnsCmaal<?sprU>
ulc ttc T
xed oprbe
ue >
Cmaao<>
oprtrT
cmaigFnto<?sprT ?etnsU kyxrco)
oprn(ucin
ue ,
xed > eEtatr
/ Seilsdpiiievrat
/ pcaie rmtv ain
pbi sai <>
ulc ttc T
Cmaao<>
oprtrT
cmaigTItucin ?sprT kyxrco)
oprn(onFnto<
ue > eEtatr
57. Summary
Syntax important, but not in the way
people think
New approaches for debugging and
testing
Take care of overloads and compiler
error messages