Questioning the status quo

Download Questioning the status quo

Post on 27-Nov-2014




10 download


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



2. WHO AM I?A software developer just like you... probably less smart than you, actuallyBy the way let's see who we are 3. WHAT WILL YOU GET OUTOF THIS TALK? 4. What will you get out of this talk?image collienSOME FOOD FOR THOUGHT AND BRAINTEASING 5. What will you get out of this talk?A PRETTY COOL LIST OF FUTUREREADINGS & VIDEOS 6. What will you get out of this talk?THINGS YOU DIDN'T KNOWTHINGS YOU ALREADY KNEWTHINGS YOU DIDN'T CARE TO KNOW 7. What will you get out of this talk?EXTRA UNSOLICITED SCALA AND FPPROMOTION! 8. LET'S START OUR JOURNEYFROM THE BEGINNINGimage Justin Overell 9. Think about your first steps in programming... 10. You probably felt excited, curious and every bit of script thatworked was so satisfying! 11. Even if you've been forced to learn programming asschoolwork, 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 thebackground, trampled by daily chores 13. We should strive to try and keep caring for what we do, andkeep alive that initial spark of passion for this activity 14. AS DEVELOPERS, AS ANINDUSTRY, WE HAVE THEPOTENTIAL TO CREATE ABETTER SOCIETYHadi Hariri from jetbrains - Codemotion Rome 2014slides available here you still care? 15. WHERE DID I GET LOST? 16. A DAILY ROUTINEMESSY ENTERPRISEY CODEBUGS, CODE SMELLS, OVER-COMPLEXITY,IMPERFECTIONSSOPHISTICATED SOLUTIONS TOPROBLEMS...... NEEDED TO SOLVE THE INDUSTRYNEEDSLIKE FASTER TIME TO MARKET ANDTIGHT DELIVERY SCHEDULES 17. THE ENTIRE AGILE MOVEMENT WASBORN TO ADAPT TO AND HANDLE THISKIND OF ISSUESAs a personal note, I recommend to take a look at the idea underlying agile, forgetting about costlycertifications and easy promises 18. Let's take a look at some code 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 submitPayment(@PathVariable("id") Order order,@RequestBody CreditCardNumber number) {if (order == null || order.isPaid()) {return new ResponseEntity(HttpStatus.NOT_FOUND);}source from payment =, number);PaymentResource resource = new PaymentResource(order.getPrice(), payment.getCreditCard());resource.add(entityLinks.linkToSingleResource(order));return new ResponseEntity(resource, HttpStatus.CREATED);} 20. code/*** Base class for entity implementations. Uses a {@link Long} id.*/@MappedSuperclass@Getter@ToString@EqualsAndHashCodepublic class AbstractEntity implements Identifiable {@Id@GeneratedValue(strategy = GenerationType.AUTO)@JsonIgnoreprivate final Long id;protected AbstractEntity() { = null;}}source from 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!topic/querydsl/4lgLx3QQqBApublic 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) 22. root-context.xmlsource from 23. pom.xml4.0.0org.springsource.restbucksrestbuckswar1.0.0.BUILD-SNAPSHOTSpring RESTBucksorg.springframework.bootspring-boot-starter-parent1.1.4.RELEASEEvans-BUILD-SNAPSHOT0.15.0.RELEASE8.0.9source from, this can get pretty verbosestill there?org.springframework.bootspring-boot-starter-data-rest 24. can get hard to decode.486PCR0_CD equ 040000000h ; Cache Disable bit of CR0CR0_NW equ 020000000h ; Not Write-through bit of CR0DisableCache procpushf ; save the flagspush eax ; save eaxcli ; disable interrupts while we do thismov eax,cr0 ; read CR0or eax,CR0_CD ; set CD but not NW bit of CR0mov cr0,eax ; cache is now disabledwbinvd ; 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 bitmov cr0,eax ; turn off the cache entirelypop eax ; restore eaxpopf ; restore the flagsret ; return to callerDisableCache endpcode endsend 25. "Traditional" enterprise code today looks just like that 26. DO WE DARE AND TRYSOMETHING DIFFERENT?image Elena Kalis 27. codepublic 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 28. codepublic 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 29. 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.Driverdb.default.url="jdbc:h2:mem:play"source from 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 30. routes.conf# Home pageGET / 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 31. build.sbtimport 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 "","jBCrypt Repository" at "","Sonatype OSS Snasphots" at "")source from's all here folkslazy val root = (project in file(".")).enablePlugins(play.PlayJava) 32. WHAT AM I TRYING TO SAY?It's too easy to get lost in cluttered technicalitiesComplex environments can blur the overall pictureEvery so often it's good to critically examine the tools we useMoreso if they result from some predetermined policyFind some time to explore new opportunities, they don'talways pay back, but sometimes they doDon't be scared by the learning curve, you've been therealready! 33. ABOUT THE "LEARNING CURVE"Rich Hickey (clojure, datomic) made interesting remarksabout the different meaning ofsimple and easypresentation available here 34. HAMMOCK DRIVEN DEVELOPMENTHickey also discussed about the creative process andproblem solving 35. HAMMOCK DRIVEN DEVELOPMENTAbout how solutions from related or unrelated fields caninspire new perspectives 36. HAMMOCK DRIVEN DEVELOPMENTAbout the need to focus 37. HAMMOCK DRIVEN DEVELOPMENTpresentation available here 38. QUIZ TIME 39. In The Art of Agile Development the author explores theconcept that source code is actually the real software designHe supports the concept with an example showing howmodern structured programming conveys the program flowmuch better than Assembly code1000 NS% = (80 - LEN(T$)) / 21010 S$ 0= ""1020 IF NS$ = 0 GOTO 10601030 S$ = S$ + " "1040 NS% = NS$ - 11050 GOTO 10201060 PRINT S$ + T$1070 RETURNSo much that we seldom need flow diagrams anymore 40. Can you make out what both of these functions do?def version1(text: String) {val center = (LENGTH - text.size) / 2var space = ""for (i