2014/11/13

Devoxx 2014: Conference day 2 Notes (13/11/2014)


keynote: Android Material Design

Chet Haase & Nick Butcher
visual design talk :-/

Modern Enterprise Java Architectures with Spring 4.1

Juergen Hoeller
Spring Framework 4.1
  • embedded webserver
  • websocket-style lightweight messaging
  • baseline:
    • min.: java 6, servlet 2.5, JPA 2.0
    • Java 8 support,
  • support:
    • servlet 3.0 oriented
    • compatible with Websphere7 (JPA feature pack)
    • Google App Engine
    • EE7 level:
      • servlet 3.1, Websockets
      • JRSR-236 Managed concurrency
      • JPA2.1, Bean validattion
      • JTA 1.2, JMS 2.0
      • JCache 1.0
    • dedicated support for latest servers
      • Tomcat 8.0, Jetty 9.2
      • GlassFish 4.2, WebLogic 12.1.3
      • Websphere Liberty Profile, WildFly
Spring 4.1 features
  • Component Classes: example meta-data (annotations) (not new)
    • @Service, @Lazy
    • @Autowired
    • @Transactional
  • Configuration classes
    • @Configuration
    • @Profile
  • Composable annotations
    • combine annotations to a “@interface” that groups multiple default annotations
    • overridable annotations: e.g. custom scopes, require specific attributes
  • Generic-based Injection Matching: look for the most specific @Bean match with @Autowired, without qualifiers;
  • ordered collection injection:
    • @Bean @Order(1)
    • @Autowired …List<> is filled with correct beans, using the @Order
  • Lazy Injection Points
  • support for standard annotations: @ManagedBean, @Inject, @PreDestroy -> no need to have spring dependencies
  • java.util.Optional (java 8)
  • Declarative formatting with Java 8 data-time:
    • base: LocalDate, LocalDateTime (java.time.*)
    • @DateTimeFormat(pattern=”M/d/yy h:mm”) (org.springframework.annotations)
    • @Past (javax.validation.constraints.*)
  • Declarative Scheduling
    • @Async
    • @Scheduled (can repeated on a single method)
  • java 8 Lambdas
    • JdbcTemplate, JmsTemplate etc.
  • Annotated MVC Controllers
    • @PathVariable from @RequestMapping(value=”/path/{id}”)
    • @Valid -> bean validation
  • STOMP on WebSocket: @SubscribeMapping
  • Annotated JMS Endpoints:
    • @JmsListener
    • Messaging abstraction: org.springframework.messaging.Message
  • Declarative Caching:
    • use spring’s annotation (not in JEE yet)
      • @CacheConfig
      • @Cacheable
      • @CachePut
      • @CacheEvict
    • or JCache JSR-107 javax.cache.annotations.
      • @CacheDefaults
      • @CacheResult
      • @CachePut
      • @CacheRemove
Demo: start.spring.io

API Design With Java 8 Lambda and Streams

Stuart Marks / Brian Goetz
API: “interface between software pieces” client / library
history:
  • java 5:
    • generics (parameterized types)
    • annotations
  • java 8
    • lambda
    • default methods
    • streams
lambda:
  • pass behavior
    • “functions as data”
    • replaces anon. inner classes
  • subclassing vs functions-as-data
    • “behavioral” patterns: Command, Iterator, Observer/Listener …
    • eg:
      • Collection -> Array -> Streams.toArray(lambda)
      • Iterator -> forEach() (state on stack, one method call)
      • conditional execution (e.g. null elements) -> iilter()
Function composition and High order functions
  • Collections.sort(List, Comparator) -> custom order with Comparator
    • Collectins.sortByType() -> too many specialized methods -> method variation is not the correct solution
    • -> revisit Comparator:
      • higher-order functions to make composing easy
      • Comparator.comparing(keyFunc)
      • Comparator.comparingInt
      • Comparator.thenComparing(): chain comparing
  • Composition / High-order functions are extremely powerful techniques!
    • Java 8 + Lambda’s
    • Strategy / Command patterns
Default Methods
  • interface evolution
  • java 8:
    • enable streams on collections
    • e.g; default remove() implementation on interface
  • reduces pressure to get interface right from the beginning
  • don’t replace abstract classes
    • no private/protected
    • no state
    • client vs subclasser interface distinction is difficult
Static methods on interfaces
  • less need for utility classes (e.g. Collections)
  • static factory methods: Comparator.comparing()
Streams in APIs
  • aggregations of other things:
    • historically: Collection
      • defensive copy
      • performance issues
    • java8: Stream
      • lazy by default
      • avoid making defensive copies
      • no need for conversion
      • can be infinite
      • (use Collection is repeatable read is required)
      • client can filter(), collect(), findFirst() on Stream
Optional
  • wrapperclass: value is present or empty
  • consider when a method can return null
  • reducess NullPointerExceptions
  • usages: min/max on empty input; find/search
  • orElse(), orElseThrow()
Generics
  • type inference relies on generics
  • raw types give issues
  • use wildcards :-/
others:
  • deprecate/remove old stuff? “removing has almost only drawbacks”

Don’t be naked in front of JavaScript: 15 essential tools explained in 15 minutes

Romain Linsolas
  • books:
    • Javascript the good parts
    • Javascript definitive guide
  • NodeJS:
    • serverside; npm
    • Express: REST
  • Yoeman: scafold project
    • yo angular
  • Bower: dependency mgmt
  • Grunt: task runner
    • config over code
    • ant for javascript
  • Gulp: Stream-besed build system
    • code over config
  • IntelliJ/ WebStorm
  • Jasmine: unit tests and functional tests
  • CasperJS: integration testing
  • Google Closure Compiler
  • SonarQube:
    • coding rules
    • test coverage
  • Batarang: Chrome extension
    • Angular debugging / profiling
    • inspect scopes
    • watch perf.

Java 8, 9 and beyond - Ask the Experts

Brian Goetz / Paul Sandoz / Stuart Marks
  • reified generics instead of erased genics: dificult with wildcards / complex within compiler -> address painpoints
    • better type literals
    • arrays: immutable
    • arraylist of int
  • jdk 9
  • parallelstreams by default -> start sequential, measure
  • backwards compatibility: burden? -> “constraint”
  • checked exceptions: failed? part of the platform.
    • difficult with generics

3D Printing, Teaching Java & Visual Programming

Michael Hoffer
3D Printing: plastic: layers of material ‘additive’ -prototyping (industry: remove layers)
How to create 3D geometries?
  • professional CAD
  • Blender (free) -> design
  • OpenSCAD
  • JCSG / JFXScad (Java libraries)
    • Union, Diff, Intersection or Hull
VRL-Studio
  • General purpose visual programming language
  • Automatic GUI gen
  • jar-file
  • JCSG Plugin -> 3d drawing
    • save as STL file -> to printing software

Pragmatic Functional Refactoring with Java 8

Raoul-Gabriel Urma / Richard Warburton
First-class Functions
  • classic: interface Predicate / implemented
  • java 8:
    • method refs: this::myMethod()
    • lambdas
  • composing functions
    • java.util.function.Predicate -> test()
      • has default methods e.g; or(), and() etc.
    • function pipelines: java.util.function.Function
      • andThen() chaining
Currying
  • DoubleUnaryOperator class
  • partial application: using some arguments and returning a new function
Immutability
  • withXxxxx() methods instead of setters that copy the object and return the modified version
  • copy objects to prevent racecondition issues with internal state
  • related
    • domain driven design: immutable value types
    • tools:
      • JSR-308: annotations
      • Mutability Detector
      • FindBugs @Immutable test
Optional Data Types
  • NullPointerException protection
  • java.util.Optional
    • single value container
    • excplicit modelling
    • must be actively unwrapped
    • construct: Optional.ofNullable(person);
    • Optional.flatMap(Person::getCar — can be chained -> return Optional value
Books:
  • Java 8 in Action
  • Java 8 Lambdas

Evening Keynote: Infinite Possibilities

Denise Jacobs
  • creativity
  • fixed (perfectionism) or growth mindset?
  • ‘release tirany of the expert’
  • adopt a beginner’s mind
  • “flow”
  • make bug lists
  • choose bigger/creative problems to solve
  • ‘culture of creativity’

No comments: