foo() generates elements with event handlers that invoke foo function
properties.
Is this an abhorrent or misthought pattern ?
It allows just the one occurence of identifier /foo/ to be changed to
/whatever/ when need arises and everything should still work.
function foo () {
var callee = arguments.calle e
if (callee.singlet on != undefined)
return callee.singleto n
if (this == window)
return new callee(argument s)
installClassFun ctions()
callee.singleto n = this
return
function installClassFun ctions() {
callee.classMet hod1 = function () {alert('1')} // global function but
property of foo
callee.classMet hod2 = function () {alert('2')}
}
}
foo()
foo.classMethod 1() // not normally invoked directly, verifies operation
Even though foo is singleton, the handlers (in question) would have to be
passed a global reference to the singleton instance (if the classMethods
were programmed to be instance of foo properties. (Also, no sense in
prototyping singleton methods)
--
Richard A. DeVenezia
properties.
Is this an abhorrent or misthought pattern ?
It allows just the one occurence of identifier /foo/ to be changed to
/whatever/ when need arises and everything should still work.
function foo () {
var callee = arguments.calle e
if (callee.singlet on != undefined)
return callee.singleto n
if (this == window)
return new callee(argument s)
installClassFun ctions()
callee.singleto n = this
return
function installClassFun ctions() {
callee.classMet hod1 = function () {alert('1')} // global function but
property of foo
callee.classMet hod2 = function () {alert('2')}
}
}
foo()
foo.classMethod 1() // not normally invoked directly, verifies operation
Even though foo is singleton, the handlers (in question) would have to be
passed a global reference to the singleton instance (if the classMethods
were programmed to be instance of foo properties. (Also, no sense in
prototyping singleton methods)
--
Richard A. DeVenezia
Comment