WebSeitz/wikilog
ClosUre
is a Product Manager/CTO with a track-record building agile product-development teams for start-ups, seeking a senior role in entrepreneurial organization building disruptive Internet-driven products.

(backlinks off) (map off)
(search off)
last edited by BillSeitz on Nov 13, 2008 6:14 pm

programming technique

at If you find yourself writing the same function over and over again with minor variations, it's time to learn about closures. They're really not that scary. Here's what you do. You write a function that contains a function. The inner function is a template for the functions that you're writing over and over again, but with variables in it for all the things that vary from one case of the function to the next. The outer function takes parameters that have the same names as those variables, and returns the inner function. Then, every place where you'd otherwise be writing yet another function, simply call the outer function, and assign the return value to the name you want the "duplicated" function to appear. Now, if you need to change how the pattern works, you only have to change it in one place: the template.

: http://www.martinfowler.com/bliki/Closure.html

note on variable-scope issues

as part of - http://www-128.ibm.com/developerworks/linux/library/l-prog2.html

http://dirtsimple.org/2005/02/optimization-surprises.html

See : | |


 




Bill Seitz, fluxent at gmail dot com, Weblog