Skip to content

Tasks_To_Do

Sven Ruppert edited this page Apr 25, 2018 · 2 revisions

Tasks to do

OK, let´s start with the workshop. First of all, we need the basic structure for this workshop. Please clone the basic structure from the given link to the git - repo.

LINK TO REPO FOR THE EVENT

compile the first class

  • add to the project

JUnit5

  • add the dependencies to the projects
  • create some tests into the class called HelloWorldServiceTest
  • let the mvn clean test run inside the docker container
  • check the coverage report

Mutation testing

  • create the mutation coverage report
  • check the coverage report

Start coding

We are now ready to work with the different jdk´s in parallel.

core-frp-since08

FunctionalInterfaces - Basics

Optional

Result

Exceptions / CheckedFunctions

Functions - Basics

Task

Extract the logic from and formulate it generic;

jdk08 - Refactoring to functional

v001

  1. Replace all anonymous classes with lambda expression.

  2. Replace for-loops with Streams

  3. create an interface with the name ImageFunctions

  4. transform the oo style ImageUtils to a functional style ImageFunctions

    • byte[] failedImage(String imageID) to Function<String, byte[]> failedImage()
    • replace the usage of the method failedImage with the function
    • convert methods for filename creation into functions
    • convert imageAsStreamRessouce into a function and replace the usage
    • convert ImageUtils into ImageFunctions completely including usage
  5. refactor the filter classes to functions

    • create an interface called FilterFunctions
    • create Function<BufferedImage, byte[]> toByteArray() to extract repetitive code from filters
    • create Function<byte[], BufferedImage> toBufferedImage() to extract the image read
      • use the function toBufferedImage
      • remove the try catch block, exception will lead to a failed image
    • convert all filter classes to filter functions at FilterFunctions
    • convert method imagePanel -> function imagePanel
    • move factory function into ImagePanel (static)
    • create Function<String, StreamResource> imageAsStreamRessouceNonCached()
  6. start using Result<T>, Case, data classes and checked functions

    • switch Info to extends Sext<String, String, Boolean, Boolean, Boolean, Boolean>
    • convert the thumbnail creation to a functional style based on Case and Result
    • convert if - blocks for image creation into a functional style
      • don´t optimize, write it clean even if you are calculating something twice
    • use now Memoizing to remove unnecessary calculation for example done by filters (grayscale/points/..)
  7. compare your result with others, start discussing

jdk09 - Refactoring to functional - reactive

v001 - functional reactive

  1. first refactorings

    • replace all if statements inside the stream int ?: statements if possible

    • extract the part that is building the transformation function

      • use the functions from the functional JDK8 version
      • extract a function that will build the transformation function
      • build first the function that will use grayscale/pointerize and rotate
      • add a curried version of the resize function
      • decide what will be the right input Type
      • move the method for creating the transformation function into the interface FilterFunctions
      • reuse or create new a Function to read the Image itself from HDD
    • extract the CPU and IO intensive parts into a Function that will transform into a CompletableFuture

  2. serverless monolith

    • create the following modules
    • init the monolith module fn init --runtime=java --name javaevents/frp-jdk09-monolith

core-frp-since10 ??

serverless-since09

ramp up FnProject

jdk10

Vaadin UI -> reduce code with var connect to FnProject

Fazit

FRP is possible since JDK8 JDK9 is not a big thing, maybe locale pub/sub JDK10 with var - good for oo style JDK11 will var for lambdas - good for FP style