Juice V0.5 Released

0 views
Skip to first unread message

Richard Wallis

unread,
Jul 10, 2009, 6:16:36 AM7/10/09
to juice-project-discuss
Juice 0.5 now released.

With great input from Jakob Voss and Nadeem Shabir we now have a
version with unit tests, distribution build, and self generation JSDoc
pages.

Godmar Back

unread,
Jul 10, 2009, 9:06:57 AM7/10/09
to juice-proj...@googlegroups.com

I think Juice is a cool project.

May I make a technical comment. I notice that you are using a manual OO approach in Juice, which is very verbose.

I have found the use of OO libraries very useful. Notably, I recommend Alex Arnell's inheritance library: http://code.google.com/p/inheritance/ which could drastically simplify the construction of Juice extensions. The library is very small (< 100 lines or so) and sufficiently powerful.

For example, take:
http://code.google.com/p/juice-project/source/browse/trunk/extensions/JuiceSimpleInsert.js
Using inheritance, it would be written as:

simpleInsertJuice = Class.create(JuiceProcess,
   initialize: function (ju, insert) {
       id = "simpleInsertSel";
       initFunc = this.startsimpleInsert;
       if(arguments.length){
           this.parent.init(id,initFunc,null,insert,ju);
           this.parent.startup(this);
       }
   },
   startsimpleInsert: function () {
        this.showInsert();
   }
}

Notice how Class.create links the prototype chains and provides you with access to the superclass via 'this.parent'.

Also works with jsdoc, as in
   /** @lends constructor */
   initialize: ....


Personally, I find it more readable than the "manual" approach.

An extension that support empty functions and abstract functions can be found here:
http://libx.org/libx-new/src/base/chrome/libx/content/libx/libxcoreclass.js

 - Godmar

Richard Wallis

unread,
Jul 10, 2009, 9:20:52 AM7/10/09
to juice-proj...@googlegroups.com
Hi Godmar,

Thanks for the suggestion - I'll certainly take a look at inheritance.
What do others think?

~Richard.

Please consider the environment before printing this email.


Find out more about Talis at www.talis.com

shared innovationTM


Any views or personal opinions expressed within this email may not be those of Talis Information Ltd or its employees. The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.


Talis Information Ltd is a member of the Talis Group of companies and is registered in England No 3638278 with its registered office at Knights Court, Solihull Parkway, Birmingham Business Park, B37 7YB.

 
 

Godmar Back

unread,
Jul 10, 2009, 9:43:25 AM7/10/09
to juice-proj...@googlegroups.com

While I'm at lecturing (please forgive me), 2 other style comments:

a) I would avoid long argument chains such as:
http://code.google.com/p/juice-project/source/browse/trunk/extensions/OpenLibrary.js
function openlibraryJuice(ju,src,text,defPanel,launchType,insert1,insert2){
Software engineers calls this a "code smell," specifically the "Long Parameter List" code smell: http://sourcemaking.com/refactoring/long-parameter-list
To void, use the "Introduce Parameter Object" refactoring (http://sourcemaking.com/refactoring/introduce-parameter-object ) which in JavaScript works particularly nicely:
/**
* @param param.src ....
* @param param.text .... etc.
function
openlibraryJuice(param) {

Then invoke with
openlibraryJuice({ src: "hhhh", ju: "....", ..... })

You'll note that this pattern is also used by the underlying library you're using, jQuery. See, for instance, jQuery.ajax(options).
The advantage is you can't screw up the parameter order, you can document your parameters at the call site, you can omit parameters that aren't needed (they're still == null in the function), and if it's a callback object, you can carry whatever callback data you want along.

b) Be careful with scoping. This:


       id = "simpleInsertSel";
       initFunc = this.startsimpleInsert;

is most likely not what you want. It defines (or overwrites) two global variables 'id' and 'initFunc'. Use 'var' as appropriate.

 - Godmar

Richard Wallis

unread,
Jul 10, 2009, 10:16:05 AM7/10/09
to juice-proj...@googlegroups.com
All comments welcome!

On 10 Jul 2009, at 14:43, Godmar Back wrote:


While I'm at lecturing (please forgive me), 2 other style comments:

a) I would avoid long argument chains such as:

This is a pattern already creeping in to the code - see: http://code.google.com/p/juice-project/source/browse/trunk/extensions/Carousel3D.js

b) Be careful with scoping. This:

       id = "simpleInsertSel";
       initFunc = this.startsimpleInsert;


Whoops! - I'm usually quite careful about slapping var on everything - well spotted.

~Richard.

Richard Wallis
Technology Evangelist, Talis
Tel: +44 (0)870 400 5422 (Direct)
Tel: +44 (0)870 400 5000 (Switchboard)
Tel: +44 (0)7767 886 005 (Mobile)

Skype: richard.wallis1





Reply all
Reply to author
Forward
0 new messages