Using the Protoype Pattern in Jade

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Using the Protoype Pattern in Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:49 pm

by Anonymous >> Tue, 17 May 2005 4:55:16 GMT

Hi,

I have a situation where I use recursive code to load a
hiearchical listbox.
I want to create a prototype listbox in jade where it gets loaded on start up and any further requirements to display the listbox simply copy the protoype listbox rather than loading from the database.
Will I have to create an invisible form with a listbox, populate that and use it as the prototype or can I create a shared transient listbox that I can load and use that?
Ive had problems with the latter method.

Any suggestions?
Regards Troy

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Using the Protoype Pattern in Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:49 pm

by allistar >> Tue, 17 May 2005 8:44:26 GMT

I assume you want to do this for performance reasons.
Have you tried converting the recursive code to be procedural and seeing what the performance improvement is?

I doubt very much you'll be able to easily copy a ListBox object, and I'm sure that controls can't exist on more than one form at a time (meaning using a shared transient won't work).

A god way of greatly improving performance on the load of large recurive structures into a list box (or combo box for that matter) is to only load the top level. Put place holder items under each parent item that has children (so you see the "+" symbol. When a parent is expanded you then remove the placeholder item and populate the direct children of this parent from the database.

This has advantage and disadvantages:
- advantage: Greatly improves form load time
- advantage: supports infinite recursive structures
- disadvantage: list box initially has all items unexpanded.

Another option is to create and populate the list box at login time and then copy the itemText and itemLevel arrays to transient collections stored on some ransient singleton object. The when disp;laying a form with this istbox copy those transient arrays to the corresponding arrays on the listbox on the form. I'm not sur is JADE lets you copy into those arrays, but I don't see why not.

Regards,
Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Using the Protoype Pattern in Jade

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:49 pm

by John Beaufoy >> Tue, 17 May 2005 12:11:21 GMT

First of all I suggest diagnosing exactly where the performance problem lies (GUI or data access?). You may find that some basic tuning can resolve the issue to avoid this extra level of complexity. Jade has some pretty useful tuning tools; with the monitor statistics, profiler and thin client trace all likely to be useful in this situation.



With Jade having to loop down through each of the child collections, the performance issue is likely a result of Jade implicitly sharelocking each of the child collections and then needing to access each object aswell. There are some other side affects which Allistar has mentioned, hopefully you would pick these up using the tools outlined above.



What about defining a persistent collection (on your root or company object I suspect) that includes all members of your hierarchy, but stored in the order that they would be displayed in your listbox. You could define additional keys on this to include the other info you need to populate the listbox (such as the itemlevel and itemtext intended values), which may or may not mean using ExternalKeyDict. Regardless, you would be able to then use the iteratorKeys methods to access the info to efficiently populate your listbox. This does mean you take the hit on maintaining this collection when you update the hierarchy, but will hopefully save when you come to display the info.



Cheers,

John Beaufoy
www.nwi.co.nz


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 29 guests