Download - Oh Oh To Functional

Transcript
Page 1: Oh Oh To Functional

Oh-Oh to FunctionalIntroduction to Functional Thinking

[email protected]@nashjain

http://nareshjain.com

Page 2: Oh Oh To Functional

AgendaObject-Oriented Design Principles (SOLID, DRY)

Functional Concepts

Single Abstract Method (SAM) Pure Functions Immutability High-Order Functions Lambda Expressions Lazy evaluation Functional Composition Declarative vs. Imperative programming style

Quick Demo - Java 8 Functional Features

Page 3: Oh Oh To Functional

Commercial Break!

Page 4: Oh Oh To Functional

http://agilefaqs.com | Copyright © 2014, AgileFAQs. All Rights Reserved.

Page 5: Oh Oh To Functional

Mumbai

Page 6: Oh Oh To Functional
Page 7: Oh Oh To Functional
Page 8: Oh Oh To Functional
Page 9: Oh Oh To Functional

Tech Talks!

Page 10: Oh Oh To Functional
Page 12: Oh Oh To Functional

2

4

5 1

2

6 4

xⁿ

57

11

Page 13: Oh Oh To Functional

Story #1

As a Kid learning arithmetics,

I want to identify even numbers

So that I can grow my understanding of odd and even numbers.

Page 14: Oh Oh To Functional

Acceptance Criteria#1

Given numbers 1, 2, 3, 4, 5 and 6

When using the Odd filter and emptying contents of the source bucket to target bucket

Then target bucket should contain 2, 4 and 6.

#2 Given numbers -2 and 3

When using the odd filter and emptying contents of the source bucket to target bucket

Then target bucket should contain -2.

Page 15: Oh Oh To Functional

1

6

2

4

5

3 7

xⁿ

9

Page 16: Oh Oh To Functional

Story #2

As a Kid learning arithmetics,

I want to identify prime numbers

So that I can differentiate between composite and prime numbers.

Page 17: Oh Oh To Functional

Acceptance Criteria#1

Given numbers 2, 4, 6, 7, 9 and 11

When using Prime filter and emptying contents of the source bucket to target bucket

Then target bucket should contain 2, 7 and 11.

#2 Given numbers -1, -2, 3, and 4

When using Prime filter and emptying contents of the source bucket to target bucket

Then target bucket should contain 3.

Page 18: Oh Oh To Functional

1

11

2

4

5

-3 4

xⁿ

9

7

Page 19: Oh Oh To Functional

Story #3

As a Kid learning arithmetics,

I want to identify odd primes

So that I can understand numbers that are odd and primes at the same time.

Page 20: Oh Oh To Functional

Acceptance CriteriaGiven numbers 2, 4, 5, 6 and 7

When using the Odd and prime filters and emptying contents of the source bucket to target bucket

Then target bucket should contain 5 and 7.

Page 21: Oh Oh To Functional

2

4

5 1

2

6 4

xⁿ

57

11

Page 22: Oh Oh To Functional

Story #4

As a Kid learning arithmetics,

I want to identify numbers within a range

So that I can grow my understanding of ranges.

Page 23: Oh Oh To Functional

Acceptance CriteriaGiven there are numbers 5, 7, 10 and 15

When using the range between 5..10 and emptying contents of the source bucket to target bucket

Then target bucket should contain 5, 7 and 10.

Page 24: Oh Oh To Functional

2

4

5

3

8

1 7

xⁿ

9

Page 25: Oh Oh To Functional

Story #5

As a Kid learning arithmetics,

I want to sum all the numbers that are in the bucket.

So that I can learn addition.

Page 26: Oh Oh To Functional

Acceptance Criteria

Given numbers 5, 7, 10 and 5

When using the aggregator and emptying contents of the source bucket to target bucket

Then target bucket should contain 27.

Page 27: Oh Oh To Functional

2

4

5 1

2

6 4

xⁿ

12

11

Page 28: Oh Oh To Functional

Story #6

As a Kid learning arithmetics,

I want to multiply all numbers in a bucket.

So that I can grow my understanding of numbers.

Page 29: Oh Oh To Functional

Acceptance Criteria

Given numbers 2, 4 and 6

When using the multiplier and emptying contents of the source bucket to target bucket

Then target bucket should contain 48.

Page 30: Oh Oh To Functional

2

4

5 1

2

6 4

xⁿ

48

11

*

Page 31: Oh Oh To Functional

Story #7

As a Kid learning arithmetics,

I want to sum all odd primes within a range.

So that I can grow my understanding of numbers.

Page 32: Oh Oh To Functional

Acceptance Criteria

Given numbers 1, 2, 5, 7, 8, 10 and 15

When using the range 2..10 and emptying contents of the source bucket to target bucket

Then target bucket should contain 12.

Page 33: Oh Oh To Functional

2

4

5 1

2

6 4

xⁿ

57

11

12

Page 34: Oh Oh To Functional

Functional Features in Java 8

Quick Demo