Thank You
Composing Software: An Introduction
You Compose Software Every Day
Conclusion
The Dao of Immutability (The Way of the Functional Programmer)
Forward
The Rise and Fall and Rise of Functional Programming (Composable Software)
The Rise of Functional Programming
The Fall of Functional Programming
The Rise of Functional Programming
Functional Programming Has Always Been Alive and Well
Why Learn Functional Programming in JavaScript?
Pure Functions
What is a Function?
Mapping
Pure Functions
The Trouble with Shared State
Same Input, Same Output
No Side Effects
Conclusion
What is Functional Programming?
Pure Functions
Function Composition
Shared State
Immutability
Side Effects
Reusability Through Higher Order Functions
Containers, Functors, Lists, and Streams
Declarative vs Imperative
Conclusion
A Functional Programmer’s Introduction to JavaScript
Expressions and Values
Types
Destructuring
Comparisons and Ternaries
Functions
Currying
Function Composition
Arrays
Method Chaining
Conclusion
Higher Order Functions
Curry and Function Composition
What is a curried function?
What is a partial application?
What’s the Difference?
What is point-free style?
Why do we curry?
Trace
Curry and Function Composition, Together
Conclusion
Abstraction & Composition
Abstraction is simplification.
Abstraction in Software
Abstraction through composition
How to Do More with Less Code
Conclusion
Reduce
Reduce is Versatile
Conclusion
Functors & Categories
Why Functors?
Functor Laws
Category Theory
Build Your Own Functor
Curried Map
Conclusion
Monads
You’re probably already using monads.
What Monads are Made of
Building a Kleisli Composition Function
The Monad Laws
Conclusion
The Forgotten History of OOP
The Big Idea
The Essence of OOP
What OOP Doesn’t Mean
What is an object?
We’ve lost the plot.
Object Composition
What is Object Composition?
Three Different Forms of Object Composition
Notes on Code Examples
Aggregation
Concatenation
Delegation
Conclusion
Factory Functions
Literals for One, Factories for Many
Returning Objects
Destructuring
Computed Property Keys
Default Parameters
Type Inference
Factory Functions for Mixin Composition
Conclusion
Functional Mixins
Motivation
What are mixins?
What is functional inheritance?
What is a functional mixin?
Composing Functional Mixins
When to Use Functional Mixins
Caveats
Conclusion
Why Composition is Harder with Classes
The Delegate Prototype
The .constructor Property
Class to Factory is a Breaking Change
Composable Custom Data Types
You can do this with any data type
Composable Currency
Lenses
Why Lenses?
Background
Lens Laws
Composing Lenses
Transducers
Why Transducers?
Background and Etymology
A Musical Analogy for Transducers
Transducers compose top-to-bottom.
Transducer Rules
Transducing
The Transducer Protocol
Conclusion
Elements of JavaScript Style
1. Make the function the unit of composition. One job for each function.
2. Omit needless code.
3. Use active voice.
4. Avoid a succession of loose statements.
5. Keep related code together.
6. Put statements and expressions in positive form.
7. Use parallel code for parallel concepts.
Conclusion: Code should be simple, not simplistic.
Mocking is a Code Smell
TDD should lead to better design.
What is a code smell?
What is a mock?
What is a unit test?
What is test coverage?
What is tight coupling?
What causes tight coupling?
What does composition have to do with mocking?
How do we remove coupling?
“Code smells” are warning signs, not laws. Mocks are not evil.
· · · · · · (
收起)
0 有用 盐午 2022-11-17 05:25:54 美国
教你一些基础的函数式编程思想/理论,并且如何用 JavaScript 来实现。最后几章是代码规范和最佳实践。覆盖范围还蛮广的,但是每个知识点讲得都不深,算是给你打个基础。最好配合 Functional-Light JavaScript 一起读。
0 有用 comxpuda 2025-01-18 14:57:57 上海
FP新手友好
0 有用 卖达芬奇的。 2021-02-26 16:42:44
一本比较详细讲函数式编程的书,讲面向对象那一部分没太看懂