This document discusses function currying as a way to refactor code to make it more concise and easier to maintain. It explains that function currying combines a function with variables to create a new function, with the variables captured by closure scope. An example is given of refactoring asynchronous REST service code using two levels of function currying to make the code more DRY and less verbose.
1 of 9
Download to read offline
More Related Content
Function currying
1. Understanding
Function Currying
Javascript / AS3
Thomas Burleson
Digital Solutions Architect
Sunday, April 29, 12
2. Anonymous Functions
Closures
Function Currying
Partial Applications
Sunday, April 29, 12
3. Function Currying:
Combine function with variables to create new function.
Variables are cached [captured] as function arguments
Outer variables are accessed via closure scope by inner Function
Sunday, April 29, 12
4. But how/why do we use Function Currying
Explore existing Javascript code
Refactor code (to remove verbosity)
Apply DRY concept
Concise Code, Easy Maintenance
Sunday, April 29, 12
5. Refactoring with DRY
Existing Code
Anonymous Functions
Closures
Function Currying
Sunday, April 29, 12