Page 1 of 1

Servoy Magazine latest posts

PostPosted: Mon Aug 26, 2013 6:08 pm
by david
Servoy Magazine has been around almost as long as Servoy has. If you haven't noticed in the past couple of years we've added video content covering some decently in-depth content. Applicable to Servoy and coding in general. Recent posts include:

Coding Session #18: Metagaming code, Powerful Stuff
Coding Session #17: Coding is !@#$ Messy
Multiple Instances of Forms (Guest author: Adrian McGilly)
Phone calls from web client with Asterisk (Guest author: Lachlan Dunlop)
Divide and conquer with Servoy headless client plugin

Oldies but Goodies:

Controller vs Foundset vs Dataset
Coding Session #7: Reusable Code Considerations
Coding Session #4: Building a Form

I'll keep this thread updated with new posts.

Re: Servoy Magazine latest posts

PostPosted: Tue Aug 27, 2013 9:46 pm
by sbutler
david wrote:Multiple Instances of Forms (Guest author: Adrian McGilly)


I have some comments for discussion on this one, so I thought it easiest to post them here than in the comment on Servoy Magazine...

Adrian, thanks for taking the time to put this all together. I do have a few issues with it though...

1. Why are you using the SolutionModel and cloning the form? application.createNewFormInstance is faster, and should have less overhead as it just creates a new runtime instance, whereas using the SolutionModel and cloning the form is touching the blueprint and runtime.

2. Your encapsulation examples aren't using encapsulation. In your examples, the end result is still calling code like forms[formName].methodName(). The only difference is that you are getting the form name dynamically. Instead, if you want to call methods across forms, you should be using an event based registration based model. So if the child form wants to call something in the parent form, then in the onLoad of the parent form, it should register its method with the child form. Then when the child form wants to do a call, it looks to see what methods are registered, and calls them. Servoy's new frameworks they will be coming out with soon will implement these techniques in their framework, so I'd suggest people take a look at those. Generally, if you have code in your solution that does forms.formName.* then there is a problem. I know we all get lazy sometimes and do this, but its really not the right way, and shouldn't be taught. Even if formName is dynamic forms[formName].methodName() is still wrong. If you think of forms like View in the MVC architecture, your having code in one view directly call another view without going through the model, and thats not ideal. Code in a form should only directly call code within itself, in a scope, in an entiy method, or a method object that has been registered via an event base registration model (like using callbacks and listeners). Some pseudo code below about the event registration model with listeners...

Code: Select all
--in parent Invoice form
function onLoad(){
   //an example scope that tracks events by a name, and which methods are listening
   scopes.events.registerListener(myListener, "InvoiceLinePriceUpdated")
}

function myListener(){
   //do something here on parent form, like update a total for amount owed
}

--in the child InvoiceLines form
function price_onDataChange(){
   //an example scope that triggers the event to run, which should execute all the methods that are listening
   scopes.events.fireEvent("InvoiceLinePriceUpdated")
}

Re: Servoy Magazine latest posts

PostPosted: Tue Aug 27, 2013 9:59 pm
by david
goldcougar wrote:Generally, if you have code in your solution that does forms.formName.* then there is a problem.


Agree with this one. We let slide if it is demo or one-off code but in general try to refactor into a best practice pattern if production code. Best practices take time and practice to develop and utilize with ease though.

Coding Session #18: Metagaming code

PostPosted: Fri Aug 30, 2013 9:25 pm
by david
What does it take to reduce your code by 10x's? Make it significantly faster?

Coding Session #18: Metagaming code: http://www.servoymagazine.com/home/2013 ... stuff.html

Re: Servoy Magazine latest posts

PostPosted: Thu Sep 05, 2013 8:20 pm
by bobcusick1332964082
Great stuff, David! Thanks for writing it up!