Page 1
Unleashing the power of patterns with angular
DMITRIY SHEKHOVTSOV
Page 5
Your most used tool?
Page 10
- singleton - factory - pub/sub - adapter
Page 11
- DI - module - IoC - CQRS
Page 13
Dependency injection<pattern>
Page 14
DEPENDENCY INJECTION
▸dependency injection is a technique whereby one object supplies the dependencies of another object.
Page 16
DI for 5-years oldJohn Munsch, 28 October 2009
Page 17
DI for 5-years old
Page 18
DI for 5-years old
Page 19
DI for 5-years old
Page 20
Do we really need DI?
Page 21
“ Dependency injection in Angular isn’t worth it
“
Page 22
WITHOUT DEPENDENCY INJECTION
Page 24
DI “common sense”
Page 35
- name space - encapsulation - structure code - manage dependencies
Page 37
- accomplish a particular function
- or contain everything necessary
to accomplish a particular task
Page 40
NgModule is Angular DI configuration point
Page 46
Shared modules & Using component from child
module
Page 47
Lazy loaded modules & using components from
parent module
Page 48
Services with the same name
Page 49
Testing module configuration
Page 55
Data StackPrimitive Values
Memory Heap
Object
Page 56
let a = {prop:1}
Data StackPrimitive Values
Memory Heap
Object
Page 57
a.prop = 2Data StackPrimitive Values
Memory Heap
Object
Page 58
Memory Heap
Old Object
Object
let a = {prop:2}
Data StackPrimitive Values
Page 59
DIRTY CHECKING<Angular js>
Page 60
Scope
Data StackPrimitive Values
Memory Heap
Object
Object
clone
Data StackPrimitive Values
Memory Heap
Object
Object
previous scope state
Page 61
previous state
Data StackPrimitive Values
Memory Heap
Object
Object
Deep diff
Data StackPrimitive Values
Memory Heap
Object
Object
Current state
Page 62
Scope
Data StackPrimitive Values
Memory Heap
Object
Object
clone
Data StackPrimitive Values
Memory Heap
Old Object
Object
previous scope state
Page 63
STRICT EQUALITY
<angular>
Page 64
previous state
Data StackPrimitive Values
Memory Heap
Object
Object
Strict quality diff
Data StackPrimitive Values
Memory Heap
Object
Object
Current state
Page 65
IMMUTABILITY<principle>
Page 66
Patterns are everywhere
Page 68
Single Responsibility<pattern>
Page 69
Chain Of Responsibility
<pattern>
Page 71
Pure functions<pattern>
Page 72
Strategy<pattern>