Skip to content

Latest commit

 

History

History
159 lines (123 loc) · 9.75 KB

ReadMe.adoc

File metadata and controls

159 lines (123 loc) · 9.75 KB

My POC Build Status Codecov License

Open in Gitpod

Introduction

This repo is for all POC which I does and learning’s I learnt Below are the projects that I have completed POC

Filing Issues

If you encounter any bug, please file an issue here.

To suggest a new feature or changes that could be made, file an issue the same way you would for a bug.

Pull Requests

Pull requests are welcome. To open your own pull request, click here. When creating a pull request, make sure you are pointing to the fork and branch that your changes were made in.

How to setup Project

This project is using lombok so you need to prepare your IDE as described here. After Setup import project as a maven project.

Jacoco

Code coverage is a software metric used to measure how many lines of our code are executed during automated tests. JaCoCo reports help you visually analyze code coverage by using diamonds with colors for branches and background colors for lines:

  • Red diamond means that no branches have been exercised during the test phase.

  • Yellow diamond shows that the code is partially covered – some branches have not been exercised.

  • Green diamond means that all branches have been exercised during the test. The same color code applies to the background color, but for lines coverage.

JaCoCo mainly provides three important metrics:

  • Lines coverage reflects the amount of code that has been exercised based on the number of Java byte code instructions called by the tests.

  • Branches coverage shows the percent of exercised branches in the code – typically related to if/else and switch statements.

  • Cyclomatic complexity reflects the complexity of code by giving the number of paths needed to cover all the possible paths in a code through linear combination. To take a trivial example, if there is no if or switch statements in the code, the cyclomatic complexity will be 1, as we only need one execution path to cover the entire code.

Generally the cyclomatic complexity reflects the number of test cases we need to implement in order to cover the entire code.

How to apply spring-formatter

To assign spring-formatter issue command after adding plugin to pom.xml

mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply

How to release a multi module project to git

Release using maven and git flow

  • git checkout -b release master(create branch release from master)

  • mvn --batch-mode release:prepare release:perform -DscmCommentPrefix="bumping versions" -DreleaseVersion=0.0.1 -DdevelopmentVersion=0.0.2-SNAPSHOT(sets comments, release version and development version)

  • git checkout master(get lastest master in local)

  • git merge --no-ff -m "Release Merge release into master" release (merge master with release/0.0.1 branch) or use git merge branchname

  • git branch -D release(delete branch release)

  • git push --all && git push --tags(push master and tags to repository)

  • mvn release:clean(deleted backupfiles from local env)

Notes:

In the context of imperative programming:

  1. List-based functional programming is eagerly evaluated.

  2. Stream() introduced in Java 8 and is the seam showing we’re not programming imperatively anymore. Is it required, though?

    1. imperative - what and how

    2. declarative - what and not how + higher order functions = FP. Code reads like the problem statement, through "internal iteration"/ "iteration on autopilot" Mutability is OK, but shared mutability is not.

  3. In OOP we encapsulate moving parts - in FP, we eliminate them.

  4. Is stream API slow - you don’t want a faster bicycle, but a rocket - EASIER TO PARALLELIZE

  5. List is bucket, Stream is pipeline. You don’t store water in a pipeline, you just move it through there.

  6. Functional composition (builder pattern) is essential.

  7. Lazy evaluation example - removing the terminal (collect) method - functions not being called anymore, as result not needed.

  8. Many languages give programming pattern, such as Groovy, but laziness not there, as it depends on implementation.

Limitations of streams:

  1. Single use only. Example where a stream is assigned to a variable, printed and then used with different filter condition. Result: IllegalStateException: stream has been operated on or closed.

    1. Concept: streams like QTips - use once and throw away.

  2. Not possible to fork in the middle. Only a single terminal operation.

  3. How do you deal with exceptions: sorry :(. Exception handling is an imperative-style idea: call a function, which calls a function, etc. and destroys your callstack.

    1. Scala has Mono monads and Either objects - provides safe handling, which is propagated and used in downstream stages. Lacks cohesion!

    2. Still good luck - we want pure functions and exceptions normally come from impurity.

Reactive systems:

  1. Came out of Microsoft research, but just a new name for old concept - system that reacts to stimuli

  2. Four pillars of reactive programming:

    1. Elasticity

    2. Message-driven

    3. Responsive

    4. Resilience - circuit breakers built in, partial access to application

  3. Close to the 80’s concept of dataflow computing: d → f → d →f

    1. Instructions ready to fire when the data is available

    2. Serverless computing (AWS Lambda) == dataflow programming. At the minute computation is ready and prepared it can run on ANY server with predefined affinity

  4. Reactive programming is FP++ - builds on lazy evaluation and functional composition

    1. Example with Flowable and subscribe on it

  5. Both Java Streams and Reactive ones push data, regular iterators pull. They are similar to Observable, you register to it and it pushes data to you.

  6. Both can return 0, 1 or more data.

  7. Java 8 Streams deal only with data. RS contain three channels (Data, Err, Complete). In RS error is just another form of data.

  8. RS are asynchronous, so you are not locked into parallelism (sync).

  9. RS can handle consumer back-pressure.

  10. Multiple subscribers in RS, where single pipeline in Java Streams

  11. Interface differences:

    1. Reactive Stream:

      • Publisher

      • Subscriber

      • Subscription - session between emitter and subscriber, can hold context

      • Processor - publisher + subscriber

      • Implementations: RxJava, Akka, Reactor (Spring 5), RSocket

    2. Java reactive streams - same interface, since Java 9 - in the java.util.concurrent.Flow.* class

Commands to ensure that dependencies are upgraded

  • mvn versions:display-plugin-updates

  • mvn versions:display-property-updates

Topics to learn

Java Memory Model Very Important
  -  https://www.youtube.com/watch?v=ZBJ0u9MaKtM
  -  http://tutorials.jenkov.com/java-concurrency/java-memory-model.html
  -  https://walkingtree.tech/design-patterns-microservices/
  -  https://springframework.guru/gang-of-four-design-patterns/state-pattern/ (State Pattern)
  -  https://techburst.io/microservices-design-patterns-a9a03be3aa5e (Diagram of design pattern)
  -  https://github.com/AnghelLeonard/Hibernate-SpringBoot (Hibernate)
  -  https://www.youtube.com/channel/UCiz26UeGvcTy4_M3Zhgk7FQ (Defog Tech esp Threads)
  -  https://www.youtube.com/channel/UCZCFT11CWBi3MHNlGf019nw (Algorithms)
  -  https://dzone.com/articles/microservices-communication-zuul-api-gateway-1
  -  https://microservices.io/patterns/microservices.html
  -  https://microservices.io/patterns/data/api-composition.html
  -  https://www.tutorialspoint.com/spring_boot/spring_boot_eureka_server.htm
  -  https://dzone.com/articles/spring-boot-autoscaler
  -  https://www.elastic.co/what-is/elk-stack
  -  https://dzone.com/articles/libraries-for-microservices-development
  -  https://logz.io/blog/kibana-tutorial/
  -  https://dzone.com/articles/magic-of-kafka-with-spring-boot
  -  https://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon
  -  https://jwt.io/introduction/
  -  https://www.springboottutorial.com/introduction-to-centralized-logging-with-microservices
  -  https://dzone.com/articles/microservices-architectures-centralized-configurat
  -  https://developers.redhat.com/blog/2019/03/12/distributed-microservices-architecture-enterprise-integration-istio-and-managed-api-gateways/
  -  https://docs.vmware.com/en/VMware-vSphere/6.7/Cloud-Native-Storage/GUID-CF1D7196-E49C-4430-8C50-F8E35CAAE060.html
  -  https://pivotal.io/cloud-native
  -  https://www.loomsystems.com/blog/single-post/2017/01/30/a-comparison-of-fluentd-vs-logstash-log-collector
  -  https://logz.io/blog/fluentd-logstash/
  -  https://www.callicoder.com/java-8-completablefuture-tutorial/
  -  https://codete.com/blog/5-common-spring-transactional-pitfalls/