if none of the two terms in the title tell you anything, you have some serious reading todo.
first off learn and love coffeescript.
so my design pattern of choice is revealing module…obviously…as the title already spoiled ;)
how to implement it in coffescript?
i wont do much explaining…so here is the code
CoolModuleNamedAfterTheControllerOrPageIuseItIn = -> ultraSecretLocalVar = 42 loadKittyImages = -> console.log("Meow!") loadFunnyImageSlider = -> console.log("Swooosh!") doSomething = -> console.log("Yes, we can!") publicMethod1 = -> doSomething() return initView = -> loadKittyImages() loadFunnyImageSlider() return publicMethod1: publicMethod1 initView: initView root = exports ? this root.CoolModuleNamedAfterTheControllerOrPageIuseItIn = CoolModuleNamedAfterTheControllerOrPageIuseItIn()
and thats basically all you need to know. (sorry no coffeescript highlighting yet). it took me a while to figure the exports thingy out, but once you built this you can simply call it with something like this:
i hope this saved you some time and/or was a helpful pointer.