DevNexus 2019 – java things that make you go huh – Bob Paulin and Freddy Guime

See the table of contents for my other blog posts from the conference

Scene 5 – singleton makes spring factory return same object each time

Scene 6 – multi release – showed exploring a jar and the alternate files. Which shows a jar can have different behavior. Nice demo of a new way to shoot yourself in the foot!

My take

I misssed 2/3 of the session. I like that each scene stood alone so I could enjoy those parts. And enjoy I did. Their costumes and characters were awesome!

DevNexus 2019 – Why and How of Evolutionary Design – Rebecca Parsons

See the table of contents for my other blog posts from the conference

  • How plan long tern architecture when under constant change
  • if on unicycle, focus on not falling. We are on the unicycle
  • evolutionary architecture is guided change
  • have to agree on what consistutes good. Not all systems need same level of security reliability, etc

Fitness function

  • how we define good.
  • Needs to be clear so no disagreement on whether the system meets. So cant just say “maintainability”
  • examples: manual vs automated, temporal, triggered vs continuous, static vs dynamic
  • think of us a test
  • chaos monkey is like a test. You know configured correctly

Principles

  • Make decisions at last responsible moment. Know the nost then
  • evolvability needs to be a first class citizen
  • how communicate across non functional requirements
  • minimize logic to minimize change. Dont do unnecessary work
  • testability
  • Conway’s law. The communication structure of your system will mimic that of organization. Communication silos in an org result in broken ntegration

Techniques

  • Continuous Delivery
  • Database refactoring – can’t migrate a system if you are being held hostage by the data
  • orchestration – the orchestra follows the conductor.
  • Consumer driven contracts. – dont have to think about until test breaks

Kinds of monoloiths

  • Ball of mud
  • layered monolyth. Can’t change without coordinating across all layers. reduce costs by standarizing everything. Slows things down. IT is an enabler and not just a cost center
  • modular monolyth
  • micro kernel architecture is only adaptable in ways you predicated. Also have to write the adapters so have more code/bugs

My take

Good talk. It was interesting and applies to almost everyone. I particularly liked the principles. I would have liked to see the slides after it got stuck. The talk was clear. But it is a long day and would have been easier to follow by visually seeing the points on principles and techniques. Im glad she acknowledged the slides not working at leaat

DevNexus 2019 – Writing Better Functional Code – Brian Vermeer

See the table of contents for my other blog posts from the conference

@brianverm

Lambda

  • Function definition not bound to an identifier
  • arguments being passed to higher order functions or used to construct higher order functions
  • In Java, like an anonymous inner function. Only exists at runtime

Lambda length

  • Want lambdas to be one line
  • If more than one line, probably have a separation of concerns problem
  • If more than one line, put it in a method with a reasonable name and use a method reference

Should you return a stream

  • A stream is not a data structure
  • Can’t reuse
  • Don’t store in a variable. Invites people to use it twice and fail.
  • No way to programmatically determine if a stream has been used
  • Useful to return streams: for private intermediate function, when new stream created every time or when result is very large or infinite
  • If not sure, return a collection instead of a stream

Mutable objects

  • Functional programming avoids changing state and mutable data
  • Less moving parts on immutable operations
  • “A stream cannot mutate” (well; isn’t supposed to)
  • Better to make a copy of the object with the desired state rather than changing the original

For each

  • It’s just a for loop
  • It can mutate state, have side effects, etc

Order of operations in stream

  • Logic
  • Infinite streams – can keep generating values and won’t stop if don’t haven’t limit or something that makes finite

Infinite stream

  • Be careful
  • Only use if needed
  • Fork/join is in an infinite pool. Will get slower and not faster with infinite data

Create higher order functions

  • Avoid duplicate code by changing “middle” of code.

Optionals

  • Java’s implementation fo the Maybe Monad
  • Encapsulation to handle possible null
  • Forces user to unpack/handle before using it.
  • Don’t set/return null for an optional. Use Optional.empty() instead
  • Use isPresent/get as a last resort. The other Optional methods are better
  • Make sure orElse() doesn’t have any side effects and only to assign a default value. Otherwise use orElseGet()

Checked exceptions and lambdas

  • Doesn’t compile
  • If want to do at point where exception happens, wrap in runtime exception and continue. Problematic because need to do it every time.
  • Alternatively, can create own functional interface that declares a checked exception and a helper method that calls the functional interface and catches the exception. This is even more ugly because abstracted further away. It’s like a wrapper function.
  • [he didn’t mention changing to an unchecked exception or a static utility to just wrap the method].
  • If want to ignore exception and process rest of stream, can use Either (a pair object), can keep track of whether there is an exception. Can implement Either yourself or use Fibers library

My take

Good content. The functional programming slide “highlighted” key words with worse contrast, but not a big deals. While this wasn’t new to me, it is good review. And if gives me arguments for my teammates when they use these anti-patterns. I like that he used some live coding. The stuff at the end was new (Either), but I felt like we were running out of time.