[NEW] Servoy Tutorials

Home for older / inactive topics

Re: [NEW] Servoy Tutorials

Postby pbakker » Thu Nov 28, 2013 10:22 am

Hi Gary,

The numbers on initial load are not the whole picture: The first two variations with both only keep a list of PK's in memory (for most of the records in case you have many), so if you start using the FS to retrieve actual records, there will be the overhead of getting the record details from the database, while in the DataSet variant all data is already in memory. So in a real caching scenario, I expect the DataSet variant to outperform FoundSets even more than just the initial load difference.

Note that off course a DataSet is disconnected from the database, so any changes you (or another client) make are not reflected in the DataSet. You could resolve this by using the onDataBroadcast event to listen for changes in the underlying tables and update the DataSet accordingly. If done right, you can keep the cached DataSet also in memory between multiple calculation runs, so you need to get the DataSet only once per client session.

Another upside of the DataSet approach is that you can flatten your datastructure for easy processing (and again reducing back and forth's to the database to retrieve related records) and get only those columns that you actually need.

Something else I forgot to mention: your memoization approach: you store the cache against "this". But "this" for regular methods (so non-constructor functions called with the "new" keyword) points to the object they belong to. So in case of form or scope method, "this" points to the scope in which the method is declared. There is no problem dynamically adding a cache property to such a scope, but if you would have 2 memoization function in one scope, their caches would collide.

As for the example code I gave: if I copy and paste my example into a Script Editor in Servoy it works fine: no parse exceptions, no warnings and proper code completion. Which version of Servoy are you using?

The reason you cannot get it to output the name of the person is probably because you store it as this.first and you try to output this.firstName

As for not seeing the prototype in David's approach: he uses Object.create, which creates a new object with the object passed into the create function as first parameter as prototype. However, when created this way, the prototype property is not exposed (don't ask me why, it just how JavaScript is designed). You can get the prototype through Object.getPrototypeOf(yourObject). So Davids approach achieves the goal, but at the cost of having to type the object using JSDoc.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: [NEW] Servoy Tutorials

Postby GaryDotzlaw » Thu Nov 28, 2013 3:29 pm

Hi Harjo,

Actually, the test results are after repeatedly running the procedures, since that better emulated the problem I was trying to solve in Optimizing Code Performance. The estimating engine in this case, was using the same foundsets over and over again.

If I do a restart between each test, I see numbers like this:
  • 29666ms - loaded in chunks
  • 7082ms - pre-load all before the loop
  • 118ms - use a dataset
If I repeatedly run the procedures, in any order, without restart, I see numbers like this:
  • 23914ms - loaded in chunks
  • 238ms - pre-load all before the loop
  • 118ms - use a dataset
So, to your point, pre-load seems to benefit more from the Servoy cache.

In my case, pre-loading the foundset before the loop, and avoiding foundset.getSize() in the for clause (cache the record count into a var and use that instead), significantly contributed to improving the estimating engine performance from 8.7secs to under 1sec in stress testing. It was a simple change to how I wrote the for loop with foundsets, and that was the entire point I was trying to communicate in the article; I did not have to do a massive code rewrite.
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [NEW] Servoy Tutorials

Postby GaryDotzlaw » Thu Nov 28, 2013 4:01 pm

Paul,

  • Thanks for the further explanation on the dataset approach. I will keep this in mind for the future. In my original case, I did not want to rewrite a lot of code, so improving performance was easily achieved by simply writing a more efficient for loop using the foundset approach. No other code changes were needed in the methods, since they were designed originally to work with foundset records.
  • I agree, function memoization is for a single cache in the function, although you can store as much as you want in that single cache. I will update the article so that no one tries more than one cache in a function that end up colliding.
  • Thank you for catching my typo in the prototype methods. Your example is working now (final code below). Parse error is gone now as well (Servoy 7.3.0 build 2018).
  • Thank you for the explanation on why David's example worked, despite not being able to see the prototype. I thought he was doing magic(another programming technique).

Code: Select all
/**
* @constructor
* @extends {personProto}
*/
function Person(first, last, title) {
   this.first = first;
   this.last = last;
   this.title = title;
}

function personProto() {
     function privateMember(){}

   this.fullName = function(){
      return this.first + " " + this.last;
   };
   this.fullNameTitle = function(){
      return this.fullName() + ", " + this.title;
   };

   /**
   * @protected
   */
   this.protectedMember = function(){
      return "You cannot see me!";
   };
}
var initPerson = (function(){
   Person.prototype = new personProto();
   Person.prototype.constructor = Person;
}())

// and then later to use
var x = new Person('SomeOther','Buddy','JavaScript Servoy Blogger');
application.output(x.fullName()) //CodeCompleting for .name() and no builder markers
// outputs SomeOther Buddy

Thanks again for the feedback.
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] 2 NEW Servoy Tutorials

Postby GaryDotzlaw » Fri Nov 29, 2013 5:30 am

I have added two more tutorials to my site. I modified the list at the start of this thread; refer to it for the complete library.

The two new tutorials are:


I hope you enjoy them!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [NEW] Servoy Tutorials

Postby david » Fri Nov 29, 2013 4:19 pm

Nice prototype inheritance and object based inheritance comparison: http://uxebu.com/blog/2011/02/23/object ... ascript-5/
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

[ANN] New Servoy Tutorial

Postby GaryDotzlaw » Sun Dec 01, 2013 8:48 pm

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The a new tutorial is:


I hope you enjoy it!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] Another Servoy Tutorial

Postby GaryDotzlaw » Tue Dec 03, 2013 8:47 pm

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The a new tutorial is:


I hope you enjoy it!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] Another Servoy Tutorial

Postby juan.cristobo » Wed Dec 04, 2013 12:22 pm

GaryDotzlaw wrote:I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The a new tutorial is:


I hope you enjoy it!


Thanks Gary, this tutorial is awesome!!
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 186
Joined: Thu Apr 19, 2012 9:12 am

Re: [NEW] Servoy Tutorials

Postby grahamg » Wed Dec 04, 2013 12:58 pm

Thanks again Gary - don't you ever sleep!

I use Arrays quite a bit - but beginning to realise how much more they can do. Really useful insights.

Cheers
Graham Greensall
Worxinfo Ltd
www.worxinfo.com
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Re: [ANN] New Servoy Tutorial

Postby GaryDotzlaw » Thu Dec 05, 2013 2:02 am

Thanks guys.
I'll sleep when I'm dead. - Bon Jovi

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The new tutorial is:

I hope you enjoy it!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] NEW Servoy Tutorial - Automated Testing

Postby GaryDotzlaw » Mon Dec 09, 2013 3:44 pm

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The new tutorial is:


I hope you enjoy it!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] New Servoy Tutorial- Using GitFlow and SourceTree

Postby GaryDotzlaw » Wed Dec 11, 2013 12:48 am

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The new tutorial is:


I hope you enjoy it!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] New Servoy Tutorial - Encapsulation

Postby GaryDotzlaw » Fri Dec 13, 2013 6:09 am

I have added a new tutorial to my site. I modified the list at the start of this thread; refer to it for the complete library.

The new tutorial is:


There is a second part coming, that demonstrates how to put the lessons learned in this tutorial to good use.

I hope you enjoy this tutorial!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] New Servoy Tutorial - Event Driven Architecture

Postby GaryDotzlaw » Mon Dec 16, 2013 5:59 pm

Sorry, I forgot to post an announcement here for a new tutorial I released on the weekend. If you like the tutorials, then please consider subscribing at my site, so you are notified when new ones are posted; I might miss posting here.

I modified the list at the start of this thread; refer to it for the complete library.

The new tutorial is:


I hope you enjoy this tutorial!
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

Re: [ANN] New Servoy Tutorials

Postby GaryDotzlaw » Fri Dec 27, 2013 6:24 pm

I released two additional tutorials a while ago, so just updating this thread.

The new tutorials are:


If you like the tutorials, then please consider subscribing at my site, so you are notified when new ones are posted.
Gary Dotzlaw
Dotzlaw Consulting
dotzlaw.com
Version: 7.3.0 - build 2018
Win 7, 64
User avatar
GaryDotzlaw
 
Posts: 38
Joined: Fri Jun 17, 2011 10:00 pm

PreviousNext

Return to Archive

Who is online

Users browsing this forum: No registered users and 0 guests