Slide 1

Slide 1 text

Functional programming James Su - 2022/05/27 Sur f ing in the changing world

Slide 2

Slide 2 text

Re-learn Actions, Calculations and Data

Slide 3

Slide 3 text

Glossary • Actions - Functions with side e ff ects • A ff ected by when and how many times they are called. • Calculations - functions without any side e ff ects • Given the same input, returns the same output. • Data - facts about events • Immutable in functional programming languages • Can be immutable in object-oriented programming languages

Slide 4

Slide 4 text

Analogy for information system

Slide 5

Slide 5 text

Usage • Thinking a problem before coding • Coding a solution • Reading existing code

Slide 6

Slide 6 text

Use case - Pending Emails

Slide 7

Slide 7 text

Reading code • Look for Actions because they need the most attention. • Find code smell without running code.

Slide 8

Slide 8 text

Reading code

Slide 9

Slide 9 text

Thinking a problem before coding • What data we will need to capture (Data) • What decisions we will need to make (Calculations) • Clarifying problems needs attention (Actions)

Slide 10

Slide 10 text

Thinking a problem

Slide 11

Slide 11 text

Coding a solution • Changeability: Actions > Calculations > Data. • Few Actions, more Calculations and Data.

Slide 12

Slide 12 text

Coding a solution

Slide 13

Slide 13 text

Solution

Slide 14

Slide 14 text

Re-learn Strati f ied design

Slide 15

Slide 15 text

Strati f ied design A technique for building software in layers.

Slide 16

Slide 16 text

What is software design? "using one’s aesthetic sense to guide programming choices to improve the ease of coding, testing, and maintaining software"

Slide 17

Slide 17 text

How strati f ied design help us to develop aesthetic senses • Straightforward implementation • Abstraction barrier • Minimal interface • Comfortable layers

Slide 18

Slide 18 text

Straightforward implementation

Slide 19

Slide 19 text

Call graph • Arrows represent function calls • Functions are in di ff erent layers Visualizing our function calls

Slide 20

Slide 20 text

Straightforward call functions from similar layers of abstraction

Slide 21

Slide 21 text

Straightforward all functions in a layer should serve the same purpose

Slide 22

Slide 22 text

Problems may exist in three levels • Interaction between layers • Implementation of one layer • Implementation of one function

Slide 23

Slide 23 text

Use call graph • Global zoom level • Layer zoom level • Function zoom level to f ind problems in di ff erent levels

Slide 24

Slide 24 text

Call graph practice Pending Emails

Slide 25

Slide 25 text

Q & A