Most developers learn to solve problems by declaring temporary variables and for loops, an anti-pattern Venkat Subramaniam calls Primitive Obession. It doesn't allow for progress when you get stuck on a difficult problem, and results in unreadable, buggy code.
Instead, solve problems using a rigorous step-by-step approach:
- Construct a domain model (only if there's a domain to model, which isn't the case for Leetcode).
- Specify type signature.
- Write a pipeline that implements the type signature (expand, transform, reduce).
- Solve the problem one step at a time by writing callbacks within the pipeline.
- Specialize the algorithms using standard library functions. ex. Sum is a specialization of plus-reduce. Length is a specialization of count-reduce.
Using a rigorous approach increases the likelihood of writing maintainable code.
Given a table of numbers, create a total column.
Step 1
empty, since there are no domain types to model.
Step 2
number[][] -> number[]
Step 3
input |> reduce rank2
Step 4
input |> Array.map (Array.reduce (+))
Step 5
input |> Array.map Array.sum
"Functional architecture - The pits of success"
- Mark Seemann, NDC Sydney 2016
https://youtu.be/US8QG9I1XW0
"From Dependency injection to dependency rejection"
- Mark Seemann, NDC London 2017
https://youtu.be/cxs7oLGrxQ4
Combinators and when to use point-free style
"Point-Free or Die: Tacit Programming in Haskell and Beyond"
by Amar Shah, Strange Loop 2016
https://youtu.be/seVSlKazsNk
"Function Composition in Programming Languages"
- Conor Hoekstra (Code Report), CppNorth 2023
https://youtu.be/JELcdZLre3s
Question: How does Blackbird relate to Inner Product?
"Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF"
by Decomplexify, 2022
https://www.youtube.com/watch?v=GFQaEYEc8_8
"Learn Database Denormalization"
by Decomplexify, 2023
https://www.youtube.com/watch?v=4bTq0GdSeQs