Part 1: Programming Style & Your Brain (00:01:54-01:15:03)
- 0:01:54 - 0:10:51 The Way We Think Our process of thought stems from two separate systems: System 1: Our Gut and System 2: Our Head.
- 0:10:52 - 0:18:01 The Programming Thought Process Computer programs are the most complicated things people make. While computer have attempted to create programs (i.e. Artificial Intelligence), they aren’t able to duplicate our system of thought. Humans right programs with the brains of hunters and gatherers.
- 0:30:35 - 0:41:40 Understanding Good Programming Style In programming, saying “That hardly ever happens” is just another way of saying “It happens”. Good programming style can help produce better programs.
- 0:41:41 - 0:50:57 Avoiding Confusing Code (A) Confusing code should be avoided. Use programming forms that avoid adding confusion.
- 0:50:58 - 1:05:38 Avoiding Confusing Code (B) Additional pitfalls emerge from the use of global variables and syntax shortcuts.
- 1:05:39 - 1:15:02 Using JSLint The JSLint style was driven by the need to automatically detect defects. Not all features of a language should be used just because they are available. The key is finding a reliable subset within the language.
- 1:41:05 - 1:52:59 Numbers Exploring the Number type and using the Math object. NaN can be confusing, but ultimately it’s the result of undefined or erroneous operation.
- 2:06:15 - 2:13:31 Objects Arrays and Object are often interchangeable. It’s best to use Objects when the names are arbitrary strings. Arrays are often more efficient when the names are sequential numbers.
Part 3: Function the Ultimate (02:24:01-03:09:01)
- 2:34:40 - 2:49:19 Functions as Subroutines The idea of a subroutine is the origin of functions. Subroutines allow for code reuse, modularity and recursion.
- 2:55:06 - 3:09:01 Prototypal Inheritance (B) Using functions as modules may be the best way to create inheritance. This module pattern can be easily transformed into a powerful constructor pattern using functional inheritance.
Part 4: Problems (03:09:02-03:48:54)
- 3:09:02 - 3:19:32 Problems 1-5 A sequence of problems will be presented followed by a solution. Each problem builds on the last so if you get a problem wrong, use the solution to begin the next problem. First, a quick quiz: What is x?
3:19:33 - 3:32:25
o Problem 6: Write a function that takes a function and an argument, and returns a function that can supply a second argument.
o Problem 7: Without writing any new functions, show three ways to create the inc function.
o Problem 8: Write methodize, a function that converts a binary function to a method.
o Problem 9: Write demethodize, a function that converts a method to a binary function.
3:32:26 - 3:37:26
o Problem 10: Write a function twice that takes a binary function and returns a unary function that passes its argument to the binary function twice.
o Problem 11: Write a function compseu that takes two unary functions and returns a unary function that calls both of them.
o Problem 12: Write a function compseb that takes two binary functions and returns a function that calls both of them.
3:37:27 - 3:48:54
o Problem 13: Write a function that allows another function to only be called once.
o Problem 14: Write a factory function that returns two functions that implement an up/down counter.
o Problem 15: Make a revocable function that takes a nice function, and returns a revoke function that denies access to the nice function, and an invoke function that can invoke the nice function until it’s revoked.
Part 5: Monads & Gonads (03:48:55-04:50:36)
- 3:48:55 - 3:58:14 Introduction to Monads Monads are a powerful functional pattern. There are two ways to use functional programming. One ways is by simply programming with function. The other way is much more mathematical.
- 4:07:30 - 4:13:09 The Ajax Monad The Ajax monad is another example of a monad design pattern. We can add the ability to bind additional methods to our monad to create Ajax functionality.
- 4:19:59 - 4:25:22 The Promise Monad (A) Promises are an excellent mechanism for managing asynchronicity. A promise is an object that represents a possible future value.
- 4:25:23 - 4:34:29 The Promise Monad (B) Using the composition pattern, a promise can be created by nesting when statements. The result will look very familiar: A promise is a monad.
4:34:30 - 4:50:36
o What is your preferred text editor?
o What is your favorite notation?