Slide 1

Slide 1 text

overfullstack.github.io

Slide 2

Slide 2 text

@GopalAkshintala - Some Manager (Not Mine!) FP is cool , coz it’s complex enough to make devs feel like they are doing something smart!

Slide 3

Slide 3 text

@GopalAkshintala

Slide 4

Slide 4 text

Dev Holy Wars @GopalAkshintala

Slide 5

Slide 5 text

IDE Theme Light Vs Dark @GopalAkshintala

Slide 6

Slide 6 text

Eclipse Vs Intellij @GopalAkshintala

Slide 7

Slide 7 text

OOP Vs FP ? @GopalAkshintala

Slide 8

Slide 8 text

@GopalAkshintala Immutability Referential Transparency Side-effects @ Boundaries FP Principles ………………………………………………… ………………………………………………… OOP Principles

Slide 9

Slide 9 text

Imperative Vs Declarative JavaDev @GopalAkshintala

Slide 10

Slide 10 text

Imperative Code - - - Imperative @GopalAkshintala

Slide 11

Slide 11 text

Let’s Concatenate last names in a team with a delimiter lastName1 lastName2 lastName2 @GopalAkshintala Team Building!

Slide 12

Slide 12 text

@GopalAkshintala What about Corner cases?

Slide 13

Slide 13 text

@GopalAkshintala lastName1 lastName2 lastName2

Slide 14

Slide 14 text

@GopalAkshintala

Slide 15

Slide 15 text

@GopalAkshintala Imperative Declarative

Slide 16

Slide 16 text

@GopalAkshintala

Slide 17

Slide 17 text

@GopalAkshintala Imperative Declarative

Slide 18

Slide 18 text

@GopalAkshintala Imperative Declarative

Slide 19

Slide 19 text

@GopalAkshintala Imperative Declarative

Slide 20

Slide 20 text

@GopalAkshintala

Slide 21

Slide 21 text

@GopalAkshintala

Slide 22

Slide 22 text

Declarative Imperative Code - - - Imperative Vs Declarative @GopalAkshintala

Slide 23

Slide 23 text

The FP part in Java The Java @GopalAkshintala

Slide 24

Slide 24 text

How to Concatenate Last names in Parallel? @GopalAkshintala

Slide 25

Slide 25 text

@GopalAkshintala

Slide 26

Slide 26 text

How-to-dos What-to-dos Looping through the list Aggregating the results Validating the names Extracting last names @GopalAkshintala

Slide 27

Slide 27 text

@GopalAkshintala

Slide 28

Slide 28 text

The Context:Core Philosophy Do Things differently without doing Different things! @GopalAkshintala

Slide 29

Slide 29 text

Stream Busted Stream Monad @GopalAkshintala

Slide 30

Slide 30 text

@GopalAkshintala Reading about Functors, Monads, Applicatives ! Kotlin Functors, Applicatives, And Monads in Pictures (3 parts) @Aballano

Slide 31

Slide 31 text

Source MayBe Monad Context Nothing Value @GopalAkshintala

Slide 32

Slide 32 text

Source @GopalAkshintala

Slide 33

Slide 33 text

Source @GopalAkshintala

Slide 34

Slide 34 text

Source @GopalAkshintala

Slide 35

Slide 35 text

Source @GopalAkshintala f(g(h(x)))

Slide 36

Slide 36 text

Monad Composability @GopalAkshintala

Slide 37

Slide 37 text

@GopalAkshintala Monad Composability

Slide 38

Slide 38 text

Are Monads used in Enterprise Software? @GopalAkshintala

Slide 39

Slide 39 text

Vader @GopalAkshintala

Slide 40

Slide 40 text

REST APIs @GopalAkshintala

Slide 41

Slide 41 text

REST Payload @GopalAkshintala

Slide 42

Slide 42 text

Simple Data Validations Nested Validations Stateful Validations @GopalAkshintala

Slide 43

Slide 43 text

The Batch Validation Framework @GopalAkshintala

Slide 44

Slide 44 text

Valid/Invalid @GopalAkshintala

Slide 45

Slide 45 text

• Configure the order of Validations • Cross-Share Common & Nested Validations • Fail-Fast or Error-Accumulation • Partial failures Framework Requirements @GopalAkshintala

Slide 46

Slide 46 text

@GopalAkshintala Validation layer Service layer DB layer Aggregated Response

Slide 47

Slide 47 text

• Accommodate a century validations • Unit testability • No compromise on Performance Framework Meta Requirements @GopalAkshintala

Slide 48

Slide 48 text

@GopalAkshintala

Slide 49

Slide 49 text

One Egg One Validation Many Eggs One Validation @GopalAkshintala

Slide 50

Slide 50 text

Many Eggs Many Validations ! @GopalAkshintala

Slide 51

Slide 51 text

Chaos @GopalAkshintala

Slide 52

Slide 52 text

Chain of Responsibility @GopalAkshintala Is FP the Best Fit?

Slide 53

Slide 53 text

@GopalAkshintala 2D Problem Eggs Validations

Slide 54

Slide 54 text

Making of a Extensible Machine @GopalAkshintala Validations Configuration Orchestration (What-to-do) (How-to-do) (How-to-do)

Slide 55

Slide 55 text

Immutable Eggs @GopalAkshintala

Slide 56

Slide 56 text

@GopalAkshintala Heterogeneous DataTypes in pipeline

Slide 57

Slide 57 text

Uniform DataTypes with Monad Boxes @GopalAkshintala

Slide 58

Slide 58 text

Either Monad Egg Validation Failure Context io.vavr.control.Either @GopalAkshintala Left Right

Slide 59

Slide 59 text

Standardize Validations @GopalAkshintala

Slide 60

Slide 60 text

@GopalAkshintala static boolean validate1Simple(Map badEggFailureBucketMap, int eggIndex, Iterator iterator, Egg eggToBeValidated) { if (!simpleOperation1(eggToBeValidated)) { iterator.remove(); badEggFailureBucketMap.put(eggIndex, NO_EGG_TO_VALIDATE_1); return false; } return true; } static final Validator validate1Simple = validatedEgg "-> validatedEgg .filter(Operations"::simpleOperation1) .getOrElse(() "-> Either.left(NO_EGG_TO_VALIDATE_1)); validate1Simple

Slide 61

Slide 61 text

@GopalAkshintala @FunctionalInterface public interface Validator extends Function1, Either> { } Validator

Slide 62

Slide 62 text

@GopalAkshintala private static boolean validate2Throwable(Map badEggFailureBucketMap, int eggIndex, Iterator iterator, Egg eggToBeValidated) { try { if (!throwableOperation2(eggToBeValidated)) { iterator.remove(); badEggFailureBucketMap.put(eggIndex, TOO_LATE_TO_HATCH_2); return false; } } catch (Exception e) { iterator.remove(); badEggFailureBucketMap.put(eggIndex, ValidationFailure.withErrorMessage(e.getMessage())); return false; } return true; } static final ThrowableValidator validate2Throwable = validatedEgg "-> validatedEgg .filterOrElse(Operations"::throwableOperation2, ignore "-> TOO_LATE_TO_HATCH_2); validate2Throwable

Slide 63

Slide 63 text

@GopalAkshintala @FunctionalInterface public interface ThrowableValidator extends CheckedFunction1, Either> { } ThrowableValidator

Slide 64

Slide 64 text

Configure the order of Validations Cross-Share Common & Nested Validations Fail-Fast or Error-Accumulation Partial failures Framework How-to-dos @GopalAkshintala

Slide 65

Slide 65 text

@GopalAkshintala Lift ThrowableValidator Validator

Slide 66

Slide 66 text

Configure the order of Validations Cross-Share Common & Nested Validations Fail-Fast or Error-Accumulation Partial failures Framework How-to-dos @GopalAkshintala

Slide 67

Slide 67 text

@GopalAkshintala Lift childValidation: Validator ParentValidation: Validator

Slide 68

Slide 68 text

@GopalAkshintala Lift Validator Validator Validator Validator

Slide 69

Slide 69 text

Configure the order of Validations Cross-Share Common & Nested Validations Fail-Fast or Error-Accumulation Partial failures Framework How-to-dos @GopalAkshintala

Slide 70

Slide 70 text

Transformation map flatMap filter Aggregation reduce collect groupBy zip,unzip foldLeft,foldRight scanLeft,scanRight @GopalAkshintala Dozen FP Operations for Daily Programming

Slide 71

Slide 71 text

Configure the order of Validations Cross-Share Common & Nested Validations Fail-Fast or Error-Accumulation Partial failures Framework How-to-dos @GopalAkshintala

Slide 72

Slide 72 text

Scalability?

Slide 73

Slide 73 text

What about Complexity? @GopalAkshintala

Slide 74

Slide 74 text

FP is NOT Complex It fights Cognitive-Complexity @GopalAkshintala

Slide 75

Slide 75 text

@GopalAkshintala Min. Cognitive-Complexity Same Time-Complexity

Slide 76

Slide 76 text

Railway-Oriented Programming Scott Wlaschin @GopalAkshintala

Slide 77

Slide 77 text

@GopalAkshintala bit.ly/imp-vs-dec bit.ly/ro-validation bit.ly/fcwfp-slides { }

Slide 78

Slide 78 text

@GopalAkshintala

Slide 79

Slide 79 text

@GopalAkshintala [email protected]

Slide 80

Slide 80 text

@GopalAkshintala