A talk about the current state of java enterprise development, evaluation of the available alternatives to conventional enterprise solutions, tools and languages for the JVM, and possibly beyond.
JUG-Roma meeting 16 Sept 2014
10. You probably felt excited, curious and every bit of script that
worked was so satisfying!
11. Even if you've been forced to learn programming as
schoolwork, you probably got addicted to it sooner or later
...otherwise you wouldn't be here today, listening to this talk
12. It can happen though, that such passion fades in the
background, trampled by daily chores
13. We should strive to try and keep caring for what we do, and
keep alive that initial spark of passion for this activity
14. “AS DEVELOPERS, AS AN
INDUSTRY, WE HAVE THE
POTENTIAL TO CREATE A
BETTER SOCIETY”
Hadi Hariri from jetbrains - Codemotion Rome 2014
slides available here www.slideshare.net/Codemotion/developing-in-a-decade
Do you still care?
16. A DAILY ROUTINE
MESSY ENTERPRISEY CODE
BUGS, CODE SMELLS, OVER-COMPLEXITY,
IMPERFECTIONS
SOPHISTICATED SOLUTIONS TO
PROBLEMS...
... NEEDED TO SOLVE THE INDUSTRY
NEEDS
LIKE FASTER TIME TO MARKET AND
TIGHT DELIVERY SCHEDULES
17. THE ENTIRE AGILE MOVEMENT WAS
BORN TO ADAPT TO AND HANDLE THIS
KIND OF ISSUES
As a personal note, I recommend to take a look at the idea underlying agile, forgetting about costly
certifications and easy promises
19. code
@Controller
@RequestMapping("/orders/{id}")
@ExposesResourceFor(Payment.class)
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PaymentController {
private final @NonNull PaymentService paymentService;
private final @NonNull EntityLinks entityLinks;
/**
* Accepts a payment for an {@link Order}
*/
@RequestMapping(value = PaymentLinks.PAYMENT, method = PUT)
ResponseEntity<PaymentResource> submitPayment(
@PathVariable("id") Order order,
@RequestBody CreditCardNumber number) {
if (order == null || order.isPaid()) {
return new ResponseEntity<PaymentResource>(HttpStatus.NOT_FOUND);
}
source from https://github.com/olivergierke/spring-restbucks
CreditCardPayment payment = paymentService.pay(order, number);
PaymentResource resource = new PaymentResource(order.getPrice(), payment.getCreditCard());
resource.add(entityLinks.linkToSingleResource(order));
return new ResponseEntity<PaymentResource>(resource, HttpStatus.CREATED);
}
20. code
/**
* Base class for entity implementations. Uses a {@link Long} id.
*/
@MappedSuperclass
@Getter
@ToString
@EqualsAndHashCode
public class AbstractEntity implements Identifiable<Long> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonIgnore
private final Long id;
protected AbstractEntity() {
this.id = null;
}
}
source from https://github.com/olivergierke/spring-restbucks
pretty terse... uh?
21. Annotatiomania
@Entity
@Table(name = "Person", catalog = "TestDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
@NamedQuery(
name = "Person.findAll",
query = "SELECT p FROM Person p"),
@NamedQuery(
name = "Person.findByPersonId",
query = "SELECT p FROM Person p WHERE p.personId = :pId"),
@NamedQuery(
name = "Person.findByPersonName",
query = "SELECT p FROM Person p WHERE p.personName = :pName"),
@NamedQuery(
name = "Person.findByPersonFamily",
query = "SELECT p FROM Person p WHERE p.personFamily = :pFamily"),
@NamedQuery(
name = "Person.findByPersonReference",
query = "SELECT p FROM Person p WHERE p.personReference = :pRef")})
source from https://groups.google.com/forum/#!topic/querydsl/4lgLx3QQqBA
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "person_id", nullable = false)
private Integer personId;
@Size(max = 50)
@Column(name = "person_name", length = 50)
23. pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springsource.restbucks</groupId>
<artifactId>restbucks</artifactId>
<packaging>war</packaging>
<version>1.0.0.BUILD-SNAPSHOT</version>
<name>Spring RESTBucks</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.4.RELEASE</version>
</parent>
<properties>
<spring-data-releasetrain.version>Evans-BUILD-SNAPSHOT</spring-data-releasetrain.version>
<spring-hateoas.version>0.15.0.RELEASE</spring-hateoas.version>
<tomcat.version>8.0.9</tomcat.version>
</properties>
<dependencies>
source from https://github.com/olivergierke/spring-restbucks
well, this can get pretty verbose
<!-- Spring Data REST -->
still there?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
24. can get hard to decode
.486P
CR0_CD equ 040000000h ; Cache Disable bit of CR0
CR0_NW equ 020000000h ; Not Write-through bit of CR0
DisableCache proc
pushf ; save the flags
push eax ; save eax
cli ; disable interrupts while we do this
mov eax,cr0 ; read CR0
or eax,CR0_CD ; set CD but not NW bit of CR0
mov cr0,eax ; cache is now disabled
wbinvd ; flush and invalidate cache
; the cache is effectively disabled at this point, but memory
; consistency will be maintained. To completely disable cache,
; the following two lines may used as well:
or eax,CR0_NW ; now set the NW bit
mov cr0,eax ; turn off the cache entirely
pop eax ; restore eax
popf ; restore the flags
ret ; return to caller
DisableCache endp
code ends
end
28. code
public class Application extends Controller {
/** Display the login page or dashboard if connected */
public static Result index() {
String email = ctx().session().get("email");
if (email != null) {
User user = User.findByEmail(email);
if (user != null && user.validated) {
return GO_DASHBOARD;
} else {
Logger.debug("Clearing invalid session credentials");
session().clear();
}
}
return ok(index.render(form(Register.class), form(Login.class)));
}
source from https://github.com/yesnault/PlayStartApp
29. code
public String validate() {
User user = null;
try {
user = User.authenticate(email, password);
} catch (AppException e) {
return Messages.get("error.technical");
}
if (user == null) {
return Messages.get("invalid.user.or.password");
} else if (!user.validated) {
return Messages.get("account.not.validated.check.mail");
}
return null;
}
source from https://github.com/yesnault/PlayStartApp
30. application.conf
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="..."
# Global object
# ~~~~~
# Define the Global object type for this application.
# Default to Global in the root package.
# global=Global
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
source from https://github.com/yesnault/PlayStartApp
#
# You can expose this datasource via JNDI if needed (Useful for JPA)
# db.default.jndiName=DefaultDS
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutions=disabled
31. routes.conf
# Home page
GET / controllers.Application.index()
GET /dashboard controllers.Dashboard.index()
POST /login controllers.Application.authenticate()
GET /logout controllers.Application.logout()
GET /settings controllers.account.settings.Index.index()
GET /settings/password controllers.account.settings.Password.index()
POST /settings/password controllers.account.settings.Password.runPassword()
GET /settings/email controllers.account.settings.Email.index()
POST /settings/email controllers.account.settings.Email.runEmail()
...
source from https://github.com/yesnault/PlayStartApp
32. build.sbt
import sbt.Keys._
name := "PlayStartApp"
version := "1.0-SNAPSHOT"
scalaVersion := "2.10.4"
libraryDependencies ++= Seq(
jdbc,
javaEbean,
cache,
"org.mindrot" % "jbcrypt" % "0.3m",
"com.typesafe" %% "play-plugins-mailer" % "2.2.0",
filters
)
resolvers ++= Seq(
"Apache" at "http://repo1.maven.org/maven2/",
"jBCrypt Repository" at "http://repo1.maven.org/maven2/org/",
"Sonatype OSS Snasphots" at "http://oss.sonatype.org/content/repositories/snapshots"
)
source from https://github.com/yesnault/PlayStartApp
It's all here folks
lazy val root = (project in file(".")).enablePlugins(play.PlayJava)
33. WHAT AM I TRYING TO SAY?
It's too easy to get lost in cluttered technicalities
Complex environments can blur the overall picture
Every so often it's good to critically examine the tools we use
Moreso if they result from some predetermined policy
Find some time to explore new opportunities, they don't
always pay back, but sometimes they do
Don't be scared by the learning curve, you've been there
already!
34. ABOUT THE "LEARNING CURVE"
Rich Hickey (clojure, datomic) made interesting remarks
about the different meaning of
simple and easy
presentation available here www.infoq.com/presentations/Simple-Made-Easy-QCon-London-2012
40. In “The Art of Agile Development” the author explores the
concept that source code is actually the real software design
He supports the concept with an example showing how
modern structured programming conveys the program flow
much better than Assembly code
1000 NS% = (80 - LEN(T$)) / 2
1010 S$ 0= ""
1020 IF NS$ = 0 GOTO 1060
1030 S$ = S$ + " "
1040 NS% = NS$ - 1
1050 GOTO 1020
1060 PRINT S$ + T$
1070 RETURN
So much that we seldom need flow diagrams anymore
41. Can you make out what both of these functions do?
def version1(text: String) {
val center = (LENGTH - text.size) / 2
var space = ""
for (i <- 0 until center) {
space += " "
}
println(space + text + space)
}
def version2(text: String) = {
def recurse(space: String): String =
if ((space*2 + text).size == LENGTH) space + text + space
else recurse(space + " ")
println(recurse(""))
}
Which version was easier to grok?
42. Before the second test we need some preparation
//A class with some simple-to-understand attributes
class Person(val name: String, val age: Int, val gender: String)
//An appendable "array-like" class
class ArrayBuffer
ready?
43. So let's rock it!
def version1(queued: Iterable[Person]): Iterable[Person] = {
val (boyz, girlz) = queued.filter(_.age > 18)
.partition(_.gender == "male")
val boyzIn = boyz take (girlz.size / 2)
val in = (boyzIn ++ girlz).to[Set]
for (boy <- boyz if !in(boy))
println(s"Go home, ${boy.name}. Better luck tommorrow, kiddo!")
in
}
def version2(queued: Iterable[Person]): Iterable[Person] = {
val girlz = ArrayBuffer[Person]()
val boyz = ArrayBuffer[Person]()
for (person <- queued) {
if (person.age > 18) {
if (person.gender == "male") boyz.append(person)
else girlz.append(person)
}
}
val in = ArrayBuffer[Person]()
in.appendAll(girlz)
for (i <- 0 until boyz.size) {
if (i < girlz.size / 2) in.append(boyz(i))
else println(s"Go home, ${boyz(i).name}. Better luck tommorrow, kiddo!")
}
return in
}
45. MAYBE WE LEARNED SOMETHING
“It is not only the violin that shapes the
violinist, we are all shaped by the tools we
train ourselves to use, and in this respect
programming languages have a devious
influence: they shape our thinking habits.”
Edsger W. Dijkstra - Letter to the budget council of The
University of Texas at Austin
the whole letter is here
www.cs.utexas.edu/users/EWD/OtherDocs/To%20the%20Budget%20Council%20concerning%20Haskell.pdf
46. WATCH OUT FOR THE
"HAMMER SYNDROME"
Try to get a deeper understanding of the tools at your
disposal
So you can take informed decisions about the best solution
to the problem at hand
"Conventional" solutions are stable but sometimes best
tailored to yesterday's problems
Look for opportunities to explore new ideas
47. A SHORT AND APPROXIMATE
PARADE OF EXPLORATION
OPPORTUNITIES FOR THE
MODERN JAVA DEVELOPER
48. AT THE DESIGN LEVEL
Conventional Unusual
CRUD Domain Driven Design
ORM Event Sourcing
MVC CQRS
49. AT THE FRAMEWORK STACK LEVEL
Conventional Unusual
Servlet Play!
JSP Vert.x
JSF Typesafe Config
Spring JOOQ
Java-EE Gradle
Maven sbt
50. AT THE LANGUAGE LEVEL
Conventional Unusual
java groovy
javascript kotlin
sql ceylon
scala
clojure
haskell!
51. Have a look at
MATT RAIBLE
'S
DEVOXX '13 PRESENTATION
to get some inspiration regarding modern web
development technologies
here is the video
www.parleys.com/play/5298cbe3e4b039ad2298c9db/
and here the slides
static.raibledesigns.com/repository/presentations/The_Modern_Java_Web_Developer_Bootcamp_Devoxx2013.pdf
[beware! heavy pdf]
53. THE OBJECT-ORIENTED VS.
FUNCTIONAL DEBATE
Even though it's hard to define both, we can try to identify
some core features of each
OOP FP
Modularity/Scoping Composability
Encapsulation (reduce
dependencies)
Abstraction
Mathematical Reasoning
(pureness & immutability)
both approaches have reusability and simplicity as goals
54. SUGGESTED READINGS ON THE
SUBJECT
D.L. Parnas - On the Criteria To Be Used in Decomposing
Systems into Modules
www.cs.umd.edu/class/spring2003/cmsc838p/Design/criteria.pdf
M.Odersky; M.Zenger - Scalable Component Abstractions
lampwww.epfl.ch/~odersky/papers/ScalableComponent.pdf
J.Hughes - Why Functional Programming Matters
www.cse.chalmers.se/~rjmh/Papers/whyfp.html
H.Abelson; G.J.Sussman - Structure and Interpretation of
Computer Programs
mitpress.mit.edu/sicp/
55. IMPEDANCE MISMATCH
OOP attaches behaviour to data
FP separates functions from data
Interestingly, the FP approach to data is considered an
anti-pattern in OOP
56. IMPEDANCE MISMATCH (DETOUR)
Object Relational Mapping has been called
“The Vietnam of Computer Science”
Ted Neward cited in
blog.codinghorror.com/object-relational-mapping-is-the-vietnam-of-computer-science/
57. IS RELATIONAL DATABASE ALWAYS THE
BEST CHOICE?
“Database Driven Development” anyone?
Once again, keep watch for opportunities!
NoSql NoDB!
61. What I'm looking after is tools that could change
THE WAY WE THINK ABOUT
PROGRAMMING
in out daily work
often with tech available even as we speak
62. TOOLS FROM THE NEAR FUTURE?
REPL
Scala Worksheet
Chris Granger's
Light Table
Elm debugger
Swift Playground
Microsoft is also researching in the area of
Live UI
Programming TouchDevelop
with along the same lines
63. As Light Table came out, Granger made some research
to figure out “what's wrong in programming”, and what kind
of solutions he could come up with
His reasoning is better explained on his blog
www.chris-granger.com/2014/03/27/toward-a-better-programming/
where he shows the progress of a new project called Aurora
Similar ideas can be found on this blog entry about
Legible Mathematics
glench.com/LegibleMathematics/
64. WOLFRAM LANGUAGE
knowledge based and cloud deployed
math functions and algorithms
data visualization
nlp
data and visualisation from many world-wide domains
everything based on symbolic functions manipulation
(includes symbols, images, docs, graphs...)
Wolfram Data Framework ontology
65. THE PEOPLE WHO IMAGINED SUCH
TOOLS
stopped thinking about what we already know about
software development
and asked what we can actually do with the technology at
our disposal
can we stop taking for granted the way we develop and
focus on how we would like to develop?
66. Most of the ideas we just saw were inspired by the creativity
of this young talented guy
BRET VICTOR
His area of interest is the future of computing, education,
data visualization and manipulation
SUGGESTED MATERIAL INCLUDES
The future of programming:
worrydream.com/#!/TheFutureOfProgramming
Inventing on principle:
worrydream.com/#!/InventingOnPrinciple
Magic Ink:
worrydream.com/#!/MagicInk
67. INFLUENCES
It strikes me how often Victor cites works and "explorers"
from the historical or contemporary computer science
research and other fields
NAMES SUCH AS
Alan Kay
Douglas Engelbart
Tony Hoare
Edsger Dijkstra
Alan Cooper
Edward Tufte
Don Norman
Jeff Raskin
David Hestenes
68. Many of these influencial people's stunning innovations,
date back to the early days of the computer age
THE POINT HERE IS
HOW MUCH CAN WE LEARN
FROM THE PAST?
69. “I have this strong feeling that the more I
look into the latest approaches or hard
problems in today's software, the more I find
myself looking back”
JUST ME
70. Whenever we discover new cool approaches and ideas
about computer science, they're probably inspired by past
research, tackling the same old fundamental issues
DESIGN PATTERNS
λ-CALCULUS
TYPE SYSTEMS
DATA REPRESENTATION
BIG DATA
DISTRIBUTED SYSTEMS
ACTORS
REACTIVE PROGRAMMING
71. QUOTING SOME HASKELL
EVANGELIST?
“One inconvenient thing about a purely imperative language is that you have
to specify far too much sequencing. For example, if you wish to do a matrix
multiplication, you have to do n³ multiplications. If you write an ordinary
program to do this, you have to specify the exact sequence which they are all
to be done. Actually, it doesn't matter in what order you do the
multiplications so long as you add them together in the right groups. Thus
the ordinary sort of imperative language imposes much too much
sequencing, which makes it very difficult to rearrange if you want to make
things more efficient.”
P.J. Landin - The Next 700 Programming Languages, 1966
www.cs.cmu.edu/~crary/819-f09/Landin66.pdf
72. THOUGH THE INFORMATION AGE IS ALL
AROUND US NOW, THE HISTORY OF
SOFTWARE AND COMPUTERS IS STILL
VERY YOUNG
TO LOOK FORWARD WE
ALSO NEED TO LOOK BACK
74. FUTURE OF: APPLICATIONS
Sep 2013
the reactive manifesto -
www.reactivemanifesto.org
Feb 2009 (first public commit)
support by the akka framework -
www.akka.io
1990 (first presentation)
inspired by erlang language -
www.erlang.org
1973
based on the actor model from Carl Hewitt - Hewitt; Bishop;
Steiger; “A Universal Modular Actor Formalism for Artificial
Intelligence. IJCAI”
75. FUTURE OF: SOFTWARE DESIGN
2012
Uncle Bob Martin quotes an article about software design
from Jack W. Reeves in his book on “Agile Software
Development, principles, patterns and practices”
1985
the author published a reply to said article, after 13 years of
reviews and comments - “What is software design: 13 years
later”
1972
the original article - “What is software design?”
1962
the idea supported in the article, that “the code, as written by
the developer, is the actual application design”, had been
already clear to Reeves for 10 years
www.developerdotstar.com/mag/articles/reeves_design_main.html
76. FUTURE OF: DATA MODELING
THE LATE WILLIAM KENT'S BOOK “DATA & REALITY”
2012 (3rd ed.)
updated and commented by Steve Hobermann
2000 (2nd ed.)
reprinted practically unchanged from the original edition
1978 (1st ed.)
1967 - a sentence, quoted in the book preface
“We do not, it seems, have a very clear and commonly agreed
upon set of notions about data - either what they are, how they
should be fed and cared for, or their relation to the design of
programming languages and operating systems” [G.H.Mealy]
Both Kent, in the first edition, and Hobermann, in the most
recent, confirm the validity of this sentence from 1967 at the
time of writing!
77. I think that innovation comes from the same open-minded
approach of those past years, when the future of computing
was still largely unwritten
LEAVING BACK SOME UNNEEDED
BAGGAGE COULD MAKE CREATIVITY
SPROUT
78. POSSIBLE VISIONS OF SOFTWARE'S
FUTURE
Paul Chiusano - The future of software, the end of apps,
and why UX designers should care about type theory
pchiusano.github.io/2013-05-22/future-of-software.html
Jamie Brandon - Imperative thinking and the making of
sandwiches
http://www.lighttable.com/2014/07/18/imperative-thinking/
79. CONCLUSIONS
The interesting problems of computer science don't seem to
have changed much over the last 50 years or so
code reasoning/ease of use
program correctness
memory allocation/GC
concurrency/parallelism
distributed computing
artificial intelligence/data mining
...
We can get a lot of inspiration from field pioneers and
research material
NEVER STOP LEARNING
80. FREEDOM
Being free is not about doing whatever we please, but about
not being constrained by our limited knowledge
82. FURTHER DISCUSSION
The problems of the past are not solved...
Why? What can we do about it?
WHAT IS YOUR POINT OF VIEW?
83. COPYRIGHTS NOTICE
Lilo & Stitch copyrights belong to Walt Disney Pictures
The Wolfram Language logo copyrights belong to Wolfram Research Inc.
Back to the future copyrights belong to Universal Studios
The Matrix copyrights belong to Warner Bros. Entertainment Inc.
Questioning The Status Quo by Ivano Pagano is licensed under a
Creative Commons Attribution-
.
NonCommercial-ShareAlike 4.0 International License
Based on a work at .
http://github.com/ivanopagano/questioning-status-quo