Hi Andy,

Andy Fuchs wrote:
> I have 2 questions about Mixin vs. static classes:
>
> I have a couple of utilities which needs to get accessed from various
> classes. Currently I put the utilities in a Mixin and included the mixin in
> the classes which need access to the utilities.
>
> Now I was wondering, if that's the *recommended* or most efficient way? It
> is much less to type (i.e. this.prepareImage vs.
> myApp.utilities.prepareImage() ).
>   

Sure enough. Mixins are fine. An important question here is whether you 
need access to instance variables in the using classes. If yes mixins 
are the way to go. If no you have the choice of either mixins or 
statics. On the other hand, if you need to maintain state centrally 
(e.g. a data structure to be used by many instances like a queue), you 
have to go for the static class.

So there are situations for both. I presume you are in a situation where 
either would be possible. If you are patching a lot of classes with 
mixins, you're extending your code base (i.e. the run time demands might 
get bigger). Statics might be a bit leaner here. But I'm not sure this 
is a big issue (they're just a bunch of function pointers...).

> Same question applies for localization:
>
> var btn1 = new qx.ui.form.Button(language.model.strings.firstbutton);
>
> vs.
>
> var btn1 = this.getString_firstbutton();
>   

That's probably "var btn1 = new 
qx.ui.form.Button(this.getString_firstbutton());", right?! I like the 
first variant better. With mixins, you also might be re-allocating a lot 
of strings over and over again, for each class using the mixin. If these 
are the same, it's more efficient to use a static class.

> Any recommendations? (I couldn't find example code throughout the web)
>   

NB: Please start a new thread if you have a new question (by posting 
directly to the list rather than replying to an existing post). - Thanks.

Thomas

> andy
>
>
>
>
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code to
> build responsive, highly engaging applications that combine the power of local
> resources and data with the reach of the web. Download the Adobe AIR SDK and
> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>   

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to