Skip to content

Commit 2c2c797

Browse files
author
Henrik Kirk
committed
Typos and correction to arch
1 parent 67ec9e5 commit 2c2c797

File tree

3 files changed

+56
-83
lines changed

3 files changed

+56
-83
lines changed

slides/08/architecture.md

Lines changed: 35 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
### Agenda
1010

1111
* Problem
12-
* IO
1312
* Ports & Adapters
1413
* Abstraction
1514
* Other
@@ -90,56 +89,6 @@ So each call to `GeneateInvoice` increments invoice number :(
9089

9190
![Invoice-lang-fp](./img/invoice-lang-fp.png)
9291

93-
94-
---
95-
96-
## IO
97-
98-
* IO is from Haskell
99-
* Used to force inpure code away from pure code
100-
* Baked in to Haskell type system
101-
102-
----
103-
104-
### Monad
105-
106-
So IO would be all the places we have side-effects aka. Infrastructure
107-
108-
* IO is a monad\*.
109-
* Another example of monads is F#'s `Option`
110-
* Monads can be combined with '`bind`'
111-
112-
\* We will come back to monads. <!-- .element: style="font-size: 20px; position: relative; bottom:0;" -->
113-
114-
----
115-
116-
#### Return and Bind
117-
118-
Two important methods for Monads are '`return`' and '`bind`'
119-
120-
```fsharp
121-
val return: 'a -> M<'a>
122-
val bind: M<'a> -> ('a -> M<'b>) -> M<'b>
123-
```
124-
125-
126-
note:
127-
128-
Monads also have some rules
129-
130-
----
131-
132-
#### Example with F#'s Option
133-
134-
```fsharp
135-
let o = Some 3 // creation or return
136-
let n = None // creation or return
137-
let f = fun a -> Some (a+3)
138-
139-
o |> Option.bind f // ...
140-
n |> Option.bind f // ...
141-
```
142-
14392
---
14493

14594
#### Hexagonal architecture
@@ -154,18 +103,20 @@ By Alistair Cockburn
154103

155104
## Ports & Adapters
156105

157-
* Components
106+
* Components<!-- .element: class="fragment" -->
158107
* loosely coupled and interchangeable
159108
* e.g. database, ui, business logic, etc. etc.
160-
* Ports
161-
* 'holes' that components can access other components through
162-
* Adapters
109+
* Ports<!-- .element: class="fragment" -->
110+
* 'interface' that components can access other components through
111+
* Adapters<!-- .element: class="fragment" -->
163112
* glue between components and ports
164113

165114
Note: Not only for FP - but very used especially in FP so e.g. F# and Haskell
166115

167116
----
168117

118+
<!-- TODO: New example -->
119+
169120
### A Resturant example
170121

171122
```fsharp
@@ -214,15 +165,15 @@ let getReservedSeats = getReservedSeatsFromDb connStr
214165
// val getReservedSeats : (Reservation -> int)
215166
```
216167

217-
So '`getReservedSeats`' are inpure - but that do not show in the signature.
168+
* <!-- .element: class="fragment" --> So 'getReservedSeats' are inpure - but that do not show in the signature.
218169

219170
----
220171

221-
### 'Problem'
172+
### Partial application
222173

223-
* Our pure function '`check`', will be inpure in production
174+
* <!-- .element: class="fragment" --> Our pure function 'check', will be inpure in production
224175

225-
* But why do checkCapacity need getReservedSeats at all? <!-- .element: class="fragment" -->
176+
* But why do 'check' need getReservedSeats at all? <!-- .element: class="fragment" -->
226177

227178
----
228179

@@ -268,26 +219,28 @@ let add1Times2' = add1 >> times2
268219

269220
### Reuse logic
270221

271-
* What is business logic?
272-
* What is application logic?
273-
* Should `reserveTable` belong in the business logic layer?
222+
* What is business logic?<br/><!-- .element: class="fragment" -->
223+
* What is application logic?<br/><!-- .element: class="fragment" -->
224+
* Does 'reserveTable' belong in the BLL?<br/><!-- .element: class="fragment" -->
274225

275226
----
276227

277-
The function `reserveTable`
278-
1. could also argue that this function is part of the controller
279-
2. thereby not something you would reuse in another application
280-
3. because:
281-
* would you always need to handle resevation validation?
228+
### The function `reserveTable`
229+
230+
1. could application logic<br/><!-- .element: class="fragment" -->
231+
1. thereby not something you would nessesary reuse<br/><!-- .element: class="fragment" -->
232+
1. because:<br/><!-- .element: class="fragment" -->
233+
* handle resevation validation in the same manner?
282234
* handle input/output different
283235

284236
----
285237

286-
### Generalization
238+
### Take-aways
287239

288-
1. Read data from impure sources
289-
2. Hand data to BLL
290-
3. Use returned data to perform side-effects
240+
1. Read data (impure)<br/><!-- .element: class="fragment" -->
241+
1. Hand data to BLL (pure)<br/><!-- .element: class="fragment" -->
242+
1. Save data (impure)<br/><!-- .element: class="fragment" -->
243+
1. Return/show data (impure)<br/><!-- .element: class="fragment" -->
291244

292245
---
293246

@@ -314,33 +267,31 @@ Is my function `a()` pure or not?
314267
----
315268

316269
### Ports and Adapters
317-
##### hexagonal architecture
318-
319-
* To avoid DAL to contaminate e.g. BLL
320-
* Alternative to layered architecture
321-
* Each component is connected through a number of ports
322-
270+
##### or hexagonal architecture
323271

324-
**Note**: Not always the correct solution
272+
* One way of avoiding DAL contaminating BLL<br/><!-- .element: class="fragment" -->
273+
* Alternative to layered architecture<br/><!-- .element: class="fragment" -->
274+
* Each component is connected through a number of ports<br/><!-- .element: class="fragment" -->
275+
* <!-- .element: class="fragment" --> Not always the correct solution
325276

326277
----
327278

328279
### Onion architecture
329280

330281
![Onion architecture](./img/onion-architecture.png) <!-- .element style="height: 260px" -->
331282

332-
* Onion architecture was inspired by Hexogonal architecture
333-
* Layered architecture
283+
* Onion architecture was inspired by Hexogonal architecture<br/><!-- .element: class="fragment" -->
284+
* Layered architecture<!-- .element: class="fragment" -->
334285
* where inner circles have no knowledge of outer circle
335286

336287

337288
----
338289

339-
### Onion pro/cons
290+
### Onion Arch. pro/cons
340291

341-
* \- e.g. database is accessible from UI
292+
* \- e.g. database is accessible from UI<br/><!-- .element: class="fragment" -->
342293
* they are in same layer - not a good idea though.
343-
* \+ fewer artifacts then ports and adapters
294+
* \+ fewer artifacts then ports and adapters<br/><!-- .element: class="fragment" -->
344295

345296
---
346297

@@ -353,6 +304,7 @@ Looks like microservices, right?
353304
----
354305

355306
### Pipe and filter
307+
##### or reactive programming
356308

357309
![Pipe and Filter](./img/pipe-and-filter.jpg "https://csblogpro.wordpress.com/2017/11/05/pipe-and-filter-architecture/")
358310

slides/08/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@
1717
<link rel="stylesheet" href="../css/highlight.js/idea.css" id="highlight-theme">
1818

1919
<script src="../../plugin/math/math.js"></script>
20+
<style>
21+
.reveal ul {
22+
list-style-type: none;
23+
}
24+
.reveal ul ul {
25+
list-style-type: none;
26+
}
27+
28+
.reveal .slides section .fragment:not(.current-fragment) {
29+
opacity: 0.3;
30+
display: inline;
31+
}
32+
.reveal .slides section .fragment.current-fragment {
33+
opacity: 1;
34+
display: inline;
35+
}
36+
</style>
2037
</head>
2138
<body>
2239
<div class="reveal">

slides/09/giraffe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
## Agenda
99

10+
* Web Framework
11+
* ASP.NET
12+
* Giraffe
13+
* HttpHandlers
1014
*
1115

1216
---

0 commit comments

Comments
 (0)