Hi Fabian, I see only one problem here. When you instantiate many instances of this anonymous class then each will leak one class declaration that will be never garbage collected (because reference will be alive to the end of application live in global class registry - class name to class object mapper).
My idea was only about lightweight anonymous classes and internally it should work like Matthew presented. Cheers - Petr 2009/10/2 Fabian Jakobs <[email protected]>: > Hi Petr, > > classes in qooxdoo cannot be anonymous, they must have a name. What you > can do is reserving a namespace for anonymous classes and just give the > classes random unique names. You can write something like this right now: > > var nextAnonymousClass = 1; > function anonymousClass(defenition) > { > var baseNs = "custom.anon"; > var className = baseNs + nextAnonymousClass; > nextAnonymousClass += 1; > > qx.Class.define(className, defenition); > > var clazz = qx.Class.getByName(className); > return new(clazz); > } > > var instance = nextAnonymousClass( > { > extend: yournamespace.YourClass, > members: > { > _getFormData: function() { > }, > > _getFormView: function() { > }, > > ... > } > }); > > > I think this could solve your problem. > > Best Fabian > > >> changing it to: >> >> var instance = new yournamespace.YourClass.override( >> { >> members: >> { >> _getFormData: function() { >> }, >> >> _getFormView: function() { >> }, >> >> ... >> } >> })(); >> >> solves the initialization after instantiation problem, but it looks ugly:) >> >> 2009/10/2 Petr Kobalíček <[email protected]>: >> >>> Hi devs, >>> >>> Intro: >>> >>> I'm thinking quite time about one concept I'm using in Java - >>> anonymous classes. For example in Java I can write: >>> >>> something = new Something() { >>> �...@override >>> void someMethod() {} >>> } >>> >>> Of course this technique should be used to define new classes with >>> only small additions, but I'm interested about using this feature in >>> qooxdoo in forms. I have own form management and databinding library >>> for qooxdoo (maybe I will release it some day, but currently it's very >>> connected with our product) and declaring anonymous forms is very >>> interesting idea. For example our form api has two parts - data part >>> (you are defining your data) and UI part (you are defining structure >>> of form) and there is problem. I need to create new class for every >>> form with only small changes. >>> >>> Concept: >>> >>> I'm thinking about override() method that will override class members >>> (I will start implementing this outside and then probably as a Mixin), >>> so the class can be declared like this way: >>> >>> var instance = new yournamespace.YourClass().override( >>> { >>> members: >>> { >>> _getFormData: function() { >>> }, >>> >>> _getFormView: function() { >>> }, >>> >>> ... >>> } >>> }); >>> >>> How this looks? I can imagine using similar technique also for table >>> row/col renderers, etc. One problem is that it overrides members after >>> instantiation. I'd like to hear what community thinks about all of >>> this. >>> >>> Cheers >>> - Petr >>> >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> qooxdoo-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >> >> >> > > > -- > Fabian Jakobs > JavaScript Framework Developer > > 1&1 Internet AG - Web Technologies > Ernst-Frey-Straße 9 · DE-76135 Karlsruhe > Telefon: +49 721 91374-6784 > [email protected] > > Amtsgericht Montabaur / HRB 6484 > Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas > Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver > Mauss, Jan Oetjen > Aufsichtsratsvorsitzender: Michael Scheeren > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
