Introduction
Thank You
Composing Software: An Introduction
You Compose Software Every Day
Composing Functions
Working Memory
Signal to Noise Ratio
Surface Area for Bugs
Composing Objects
Conclusion
Exercise 1
The Dao of Immutability (The Way of the Functional Programmer)
Forward
Exercise 2
Quiz 1
3 attempts allowed
The Rise and Fall and Rise of Functional Programming (Composable Software)
The Rise of Functional Programming
Exercise 3
The Fall of Functional Programming
The Rise of Functional Programming
Functional Programming Has Always Been Alive and Well
Quiz 2
3 attempts allowed
Why Learn Functional Programming in JavaScript?
What JavaScript is Missing
What JavaScript Has that Pure Functional Languages Lack
Quiz 3
3 attempts allowed
Pure Functions
What is a Function?
Exercise 4
Mapping
Exercise 5
Pure Functions
Exercise 6
The Trouble with Shared State
Exercise 7
Same Input, Same Output
Exercise 8
No Side Effects
Immutability
Exercise 9
Conclusion
Exercise 10
Quiz 4
3 attempts allowed
What is Functional Programming?
Pure Functions
Exercise 11
Function Composition
Shared State
Exercise 12
Immutability
Exercise 13
Side Effects
Exercise 14
Reusability Through Higher Order Functions
Exercise 15
Containers, Functors, Lists, and Streams
Exercise 16
Declarative vs Imperative
Conclusion
Exercise 17
Quiz 5
3 attempts allowed
A Functional Programmer’s Introduction to JavaScript
Expressions and Values
var, let, and const
Types
Exercise 18
Destructuring
Comparisons and Ternaries
Exercise 19
Functions
Signatures
Default Parameter Values
Named Arguments
Rest and Spread
Exercise 20
Currying
Exercise 21
Function Composition
Exercise 22
Arrays
Exercise 23
Method Chaining
Exercise 24
Conclusion
Quiz 6
3 attempts allowed
Higher Order Functions
Exercise 25
Quiz 7
3 attempts allowed
Curry and Function Composition
What is a curried function?
Exercise 26
What is a partial application?
What’s the Difference?
Exercise 27
What is point-free style?
Exercise 28
Why do we curry?
Exercise 29
Trace
Exercise 30
Curry and Function Composition, Together
Exercise 31
Conclusion
Exercise 32
Quiz 8
3 attempts allowed
Abstraction & Composition
Exercise 33
Abstraction is simplification.
Exercise 34
Abstraction in Software
Exercise 35
Abstraction through composition
Exercise 36
How to Do More with Less Code
Exercise 37
Conclusion
Exercise 38
Reduce
Exercise 39
Reduce is Versatile
A Word on Redux
Exercise 40
Conclusion
Quiz 9
3 attempts allowed
Abstract Data Types and the Software Crisis
Common ADT Examples
Exercise 41
Why ADTs?
History of ADTs
Exercise 42
Specifications for ADTs
Exercise 43
Stack ADT Example
Definitions
Abstract Signatures
Construction
Stack Operations (operations which return a stack)
Axioms
Identity
Sequence
Empty
Exercise 44
Concrete Implementations
Exercise 45
Conclusion
Exercise 46
Glossary
Quiz 10
3 attempts allowed
Functors & Categories
Exercise 47
Why Functors?
Exercise 48
Functor Laws
Identity
Composition
Exercise 49
Category Theory
Exercise 50
Build Your Own Functor
Exercise 51
Curried Map
Exercise 52
Conclusion
Exercise 53
Quiz 11
3 attempts allowed
Monads
Exercise 54
You’re probably already using monads.
Exercise 55
What Monads are Made of
Exercise 56
Building a Kleisli Composition Function
Exercise 57
The Monad Laws
Left and right identity laws
Associativity law
Identity Laws
Associativity
Proving the Monad Laws
Exercise 58
Conclusion
Exercise 59
Quiz 12
3 attempts allowed
The Forgotten History of OOP
Exercise 60
The Big Idea
Exercise 61
The Essence of OOP
Exercise 62
What OOP Doesn’t Mean
Exercise 63
What is an object?
Exercise 64
We’ve lost the plot.
Characteristics of Message Passing
Exercise 65
Quiz 13
3 attempts allowed
Object Composition
Exercise 66
What is Object Composition?
Exercise 67
Three Different Forms of Object Composition
Exercise 68
Notes on Code Examples
Exercise 69
Aggregation
Examples
When to use
Considerations
In Code
Exercise 70
Concatenation
Examples
When to Use
Considerations
In Code
Exercise 71
Delegation
Examples
When to Use
Considerations
In Code
Exercise 72
Conclusion
Exercise 73
Quiz 14
3 attempts allowed
Factory Functions
Exercise 74
Literals for One, Factories for Many
Exercise 75
Returning Objects
Exercise 76
Destructuring
Exercise 77
Computed Property Keys
Default Parameters
Exercise 78
Type Inference
Exercise 79
Factory Functions for Mixin Composition
Exercise 80
Conclusion
Quiz 15
3 attempts allowed
Functional Mixins
Exercise 81
Motivation
Exercise 82
What are mixins?
Exercise 83
What is functional inheritance?
Exercise 84
What is a functional mixin?
Exercise 85
Composing Functional Mixins
Exercise 86
When to Use Functional Mixins
Exercise 87
Caveats
Classes
Class Performance
Implicit Dependencies
Functional Mixins & Functional Programming
Exercise 88
Conclusion
Exercise 89
Quiz 16
3 attempts allowed
Why Composition is Harder with Classes
Exercise 90
The Delegate Prototype
Exercise 91
The .constructor Property
Exercise 92
Class to Factory is a Breaking Change
Code that Requires new Violates the Open/Closed Principle
The class Keyword and extends
Friendly Syntax
Performance and Memory
Type Checking
Class Inheritance with extends
Classes are OK if You’re Careful
Exercise 93
Quiz 17
3 attempts allowed
Composable Custom Data Types
Exercise 94
You can do this with any data type
Composable Currency
Exercise 95
Quiz 18
3 attempts allowed
Lenses
Exercise 96
Why Lenses?
Exercise 97
Background
Lens Laws
Exercise 98
Composing Lenses
Over
Exercise 99
Quiz 19
3 attempts allowed
Transducers
Exercise 100
Why Transducers?
Exercise 101
Background and Etymology
A Musical Analogy for Transducers
Exercise 102
Transducers compose top-to-bottom.
Exercise 103
Transducer Rules
Initialization
Early Termination
Completion
Exercise 104
Transducing
Exercise 105
The Transducer Protocol
Exercise 106
Conclusion
Exercise 107
Quiz 20
3 attempts allowed
Elements of JavaScript Style
Exercise 108
1. Make the function the unit of composition. One job for each function.
Exercise 109
2. Omit needless code.
Omit needless variables.
Exercise 110
3. Use active voice.
Event Handlers
Lifecycle Methods
Exercise 111
4. Avoid a succession of loose statements.
Exercise 112
5. Keep related code together.
6. Put statements and expressions in positive form.
If Statements
Ternaries
Prefer strong negative statements.
Avoid null and undefined arguments in function calls.
Exercise 113
7. Use parallel code for parallel concepts.
Exercise 114
Conclusion: Code should be simple, not simplistic.
Exercise 115
Quiz 21
3 attempts allowed
Mocking is a Code Smell
Exercise 116
TDD should lead to better design.
Exercise 117
What is a code smell?
Exercise 118
What is a mock?
Exercise 119
What is a unit test?
Exercise 120
What is test coverage?
Exercise 121
What is tight coupling?
Exercise 122
What causes tight coupling?
Exercise 123
What does composition have to do with mocking?
Exercise 124
How do we remove coupling?
Use pure functions
Isolate side-effects from the rest of your program logic
Use pub/sub
Isolate logic from I/O
Use objects that represent future computations
Exercise 125
“Code smells” are warning signs, not laws. Mocks are not evil.
Mocking is great for integration tests
Exercise 126
Quiz 22
3 attempts allowed
Composing Software
An Exploration of Functional Programming and Object Composition in JavaScript
Composing Software
An Exploration of Functional Programming and Object Composition in JavaScript
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
The instructor is letting you choose the price you pay for this course!
The instructor is letting you choose the price you pay for this course!
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
About
About the Course
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
In "Composing Software", Eric Elliott shares the fundamentals of composition, including both function composition and object composition, and explores them in the context of JavaScript. The course covers the foundations of both functional programming and object oriented programming to help the reader better understand how to build and structure complex applications using simple building blocks.
You'll learn:
- Functional programming
- Object composition
- How to work with composite data structures
- Closures
- Higher order functions
- Functors (e.g., array.map)
- Monads (e.g., promises)
- Transducers
- Lenses
All of this in the context of JavaScript, the most used programming language in the world. But the learning doesn't stop at JavaScript. You'll be able to apply these lessons to any language. This course is about the timeless principles of software composition and its lessons will outlast the hot languages and frameworks of today. Unlike most programming books, this one may still be relevant 20 years from now.
The book this course is based on began life as a popular blog post series that attracted hundreds of thousands of readers and influenced the way software is built at many high growth tech startups and fortune 500 companies.
Price
Course Price
Minimum price
$129.00
$179.00
You pay
$179.00Author earns
$143.20Instructor
About the Instructor
Eric Elliott
Eric Elliott is a Webby-nominated software engineering expert, author, and creator of SudoLang, an AI programming language. With over 10 years of experience deploying AI models at scale to millions of users, he built and trained production AI models, and was an early pioneer of prompt engineering and AI Driven Development (AIDD). He has served as an engineering manager working on Generative AI for Adobe Firefly, tech lead on a social video AI app spun out of Stanford Research Institute, and a JavaScript expert and consultant on software development productivity and AIDD.

Episode 301
An Interview with Eric Elliott
Material
Course Material
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.