Module Visibility in Servoy 6.0

Hi all,

I’m having problems getting my head around the ways modules work in Servoy 6.0.

I have an MAIN app.
This uses modules for ACCOUNTING, CRM, CORRESPONDENCE, REPORTING and NAVIGATION.
The problem is that some of these modules need to see and use some stuff in MAIN or ACCOUNTING. They are no longer true independent modules, they are there to organise my code… I don’t expect to drop them into another project.
I reuse the forms and basic logic in CORRESPONDENCE in 3 other modules. The CORRESPONDENCE module can’t auto-generate emails with ACCOUNTING or CRM information, so some logic dependent on the these modules have ended up in CORRESPONDENCE.

I’m now tempted to get rid of all the visibility-related errors by merging all my modules together…

Any other ideas?

Hi Christian,

I think you have 2 options:

  1. refactor your code so that there are no circulair references anymore. This means splitting up modules into smaller modules. This way functionality can ‘bubble up’. So all shared code will in it’s own ‘bottom level’ module that are referenced by other ‘top level’ modules.
    There are many ways to model this. For example I like to put all my global variables, relations, calculation into one ‘model’ module (model in the meaning of MVC) and other shared code in another. Also having a graphical representation of the module hierarchy (on paper) will help you to stay sane.

  2. Link all modules just to the main solution and use weak references to your code in other modules. So that means you use the following notation:

globals['nameOfGlobalMethod']();
forms['formName'].controller.loadAllRecords();
foundset['relationName'].fieldName;
// etc.

I think you get the idea.

In any case you need to do something about it in Servoy 6 because circular referenced modules are considered errors in that version. Which means you can’t export your solution from your workspace without solving these errors first.

Hope this helps.

Hi Robert,

I’m using MVC with Rails, so I’m familiar with the concept.

Have tried both a top-level and a bottom-level module to see if this helps without solving the issue.

I need to get rid of the circular references reasonably quickly to keep on track with a large conversion to 6.0. I’m using a lot of weak references already, but would prefer to get rid of them to get Servoy to to more stringent checking of my code. I’m finding some difficult-to-spot errors using Servoy 6.

Also, I’m trying to reduce the number of global variables.
My current thought is to reduce the number of modules, rather than increase…