Programming Design Patterns
Design Considerations
- Maintainability
- Ease of Development
- Functionality
Design Patterns
- Object Oriented Programming
- Functional Programming
You can have it all!
Object Oriented Programming
Characteristics
- Persistent State
- Side Effects
Techniques
- Inheritance
- Encapsulation
- Polymorphism
Consequences
- Familiarity
- Ease of Development
- Scope Control
Functional Programming
Characteristics
- First Class Objects
- Referential Transparency (Purity)
- Function Composition
- Immutability
- Declarative
//PURE FUNCTION !!!!!!!!!
const addTwoNumbers = function(a,b){
return a + b
}
addTwoNumbers(1,3) //This will ALWAYS be 4
//IMPURE FUNCTIONS !!!!!!!!!
let userName = 'Functor The Funky '
const AddToUserName = function(stringToAdd){
return userName += stringToAdd
}
const removeFromUserName = function(stringToAdd){
return userName -= stringToAdd
}
mutateUserName(userName,'Function') //'Functor The Funky Function'
Techniques
- Higher Order Functions
- Currying
- Partial Execution & Closures
- Recursion
- Loops mutate state!
- Memoization
Consequences
- Seperation of Concerns
- Reduction in lines of code
- Ease of parallelization
- Formal proofs of programs!
Anti-Patterns
Go forth and prosper
Design Patterns
By Mike Hathaway
Design Patterns
- 393