On 09/09/10 23:46, panyasan wrote:
> Which, to close the issue, means that you can define variables outside the
> class definition, as use them inside the qooxdoo class as super-safe data
> containers. This might be worth mentioning in the docs. They won't be
> documented in the API viewer, but that's part of the idea. Doug Crockford
> suggests to save session, password or other sensitive data vulnerable to XSS
> attacks in such variables.

i'd like to point out that such variables are private static variables,
and not private instance variables. so they're orthogonal to what
qooxdoo offers with its double-underscore prefixed variables.

you can "emulate" private instance vars with closure vars. but first
some background:

in case you need to replicate C++ templates-like functionality in
languages that support closures, like javascript and python, you can do
this:

def get_application(template_argument):
    # a class that does something with the template argument
    class Application(object):
        def get_template_argument(self):
            return template_argument

    return Application

this will instantiate a new class definition every time its parent
function is called, which is not unlike how C++ compilers implement
templates.

doing this in qooxdoo is a little problematic though:

var get_application = function(template_argument) {
    // a class that does something with the template argument
    return qx.Class.define('test.Application', {extend: qx.Core.Object
        ,members: {
            get_template_argument: function() {
                return template_argument
            }
        }
    }
}

here, how do we name the class? i don't know the answer to that. it'd be
nice to agree on a canonical way to do that though.

so, if you want to treat closure variables like private instance
variables, you need to instantiate a class definition for each class
instance. which is not possible with qooxdoo classes due to the above
reason.

but for use-cases like holding session identifiers, private statics will
certainly do the job. i agree with christian that this would do a nice
addition to the documentation.

best regards
burak



------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to